Advertisement
nicuvlad76

Untitled

Jan 21st, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define N 101
  3. using namespace std;
  4. ifstream fin("sumpow2.in");
  5. ofstream fout("sumpow2.out");
  6. char a[N],b[N],c[N];
  7. long long puteri[20],sum;
  8.  
  9. int main()
  10. {
  11. puteri[0]=1;
  12. for(int i=1;i<=16;i++)puteri[i]=2*puteri[i-1];
  13. fin>>a>>b;
  14. for(int i=0;a[i];i++)
  15. sum+=puteri[a[i]-'a'];
  16. for(int i=0;b[i];i++)
  17. sum+=puteri[b[i]-'a'];
  18. int k=0;
  19. for(int i=16;i>=0;i--)
  20. if(sum>=puteri[i])
  21. {
  22. c[k++]='a'+i;
  23. sum-=puteri[i];
  24. }
  25. for(int i=k-1;i>=0;i--)
  26. fout<<c[i];
  27. return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement