fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef vector<bool> vb;
  5. typedef vector<vb> vvb;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef vector<ll> vl;
  9. typedef vector<vl> vvl;
  10. typedef vector<char> vc;
  11. typedef vector<vc> vvc ;
  12. typedef vector<string> vs;
  13. typedef vector<pair<ll, ll> > vp;
  14. typedef pair<ll, ll> pl;
  15.  
  16. #define endl "\n"
  17. #define pb push_back
  18. #define F first
  19. #define S second
  20. #define all(v) v.begin(), v.end()
  21. #define rall(v) v.rbegin(), v.rend()
  22. #define sz(a) int(a.size())
  23. const ll mod = 1e9+7;
  24.  
  25. void solve(){
  26. ll x, y, s;
  27. cin >> x >> y >> s;
  28.  
  29. ll mx=-1, my=-1;
  30.  
  31. ll auxn=x;
  32. while(auxn){
  33. mx = max(mx, auxn%10);
  34. auxn/=10;
  35. }
  36.  
  37. auxn=y;
  38. while(auxn){
  39. my = max(my, auxn%10);
  40. auxn/=10;
  41. }
  42.  
  43. for(ll i=mx+1; i<=10; i++){
  44. for(ll j=my+1; j<=10; j++){
  45. ll auxx=x, auxy=y, sumx=0, sumy=0;
  46.  
  47. ll it=0;
  48. while(auxx){
  49. sumx += auxx%10 * pow(i, it);
  50. auxx/=10;
  51. it++;
  52. }
  53.  
  54. it=0;
  55. while(auxy){
  56. sumy += auxy%10 * pow(j, it);
  57. auxy/=10;
  58. it++;
  59. }
  60.  
  61. if(sumy+sumx == s){
  62. cout << i << " " << j << endl;
  63. return;
  64. }
  65. }
  66. }
  67.  
  68.  
  69.  
  70. }
  71.  
  72. int main(){
  73. ios::sync_with_stdio(false);
  74. cin.tie(nullptr);
  75.  
  76. int tt=1;
  77.  
  78. // cin >> tt;
  79.  
  80. while(tt--){
  81. solve();
  82. }
  83. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty