Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
948 B
1
Indexable
Never
int main()
{
    int a,b;
    cin>>a>>b;
    unordered_set<string> arr;
    string sa = to_string(a);
    string sb = to_string(b);
    int n = sa.size();
    for(int i=0;i<(1<<n);i++){
        string s;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                s+=sa[j];
            }
        }
        if(s.size()>=1){
            if(s[0]!='0'){
             arr.insert(s);
            }else if(s[0]=='0' && s.size()==1){
                arr.insert("0");
            }
        }
    }
    unordered_set<int> ans;
    n = sb.size();
    for(int i=0;i<(1<<n);i++){
        string s;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                s+=sb[j];
            }
        }
        if(s.size()>=1){
            if(arr.count(s)){
                ans.insert(stoi(s));
            }
        }
    }
    for(auto num:ans){
        cout<<num<<" "<<num<<endl;
    }
    return 0;
}