senb1

krsu 856

Feb 20th, 2023
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. /*
  2. by: senb1
  3. */
  4.  
  5. #include <bits/stdc++.h>
  6.  
  7. #define ll long long
  8. #define all(x) x.begin(), x.end()
  9. #define fr first
  10. #define sc second
  11. #define mk make_pair
  12.  
  13. using namespace std;
  14.  
  15. const ll mod = 1000;
  16.  
  17. ll binpow(ll x, ll y) {
  18.     ll res = 1;
  19.     while (y) {
  20.         if (y & 1)
  21.             res = (res * x) % mod;
  22.         x = (x * x) % mod;
  23.         y >>= 1;
  24.     }
  25.     return res;
  26. }
  27.  
  28. void solve() {
  29.     int f1, f2, f3, f4, f5, f6;
  30.     cin >> f1 >> f2 >> f3 >> f4 >> f5 >> f6;
  31.  
  32.     int mxcnt = 0;
  33.     for (int a = 0; a < 10; a++) {
  34.         for (int b = 0; b < 10; b++) {
  35.             for (int c = 0; c < 10; c++) {
  36.                 int cnt = 0;
  37.                 for (int d = 0; d < 10; d++) {
  38.                     if (f1 == a + b + c + d)
  39.                         cnt++;
  40.                     if (f2 = 8 * a + 4 * b + 2 * c + d)
  41.                         cnt++;
  42.                     if (f3 == 27 * a + 9 * b + 3 * c + d)
  43.                         cnt++;
  44.                     if (f4 == 64 * a + 16 * b + 4 * c + d)
  45.                         cnt++;
  46.                     if (f5 == 125 * a + 25 * b + 5 * c + d)
  47.                         cnt++;
  48.                     if (f6 == 216 * a + 36 * b + 6 * c + d)
  49.                         cnt++;
  50.                     if (cnt >= 5) {
  51.                         cout << 1000 * a + 100 * b + 10 * c + d;
  52.                         return;
  53.                     }
  54.                     cnt = 0;
  55.                     mxcnt = max(mxcnt, cnt);
  56.                 }
  57.             }
  58.         }
  59.     }
  60. }
  61. /*
  62.  * f1 = a + b + c + d;
  63.  * f2 = 8a + 4b + 2c + d;
  64.  * f3 = 27a + 9b + 3c + d;
  65.  * f4 = 64a + 16b + 3c + d;
  66.  * f5 = 125a + 25b + 5b + d;
  67.  * f6 = 216a + 36b + 6c + d;
  68.  */
  69.  
  70. int main() {
  71.     ios::sync_with_stdio(0);
  72.     cin.tie(0);
  73.  
  74.     int t = 1;
  75.     // cin >> t;
  76.     while (t--)
  77.         solve();
  78. }
  79.  
Advertisement
Add Comment
Please, Sign In to add comment