Advertisement
Hezov

Q21 Unibuc fara explicatii

Dec 17th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. using namespace std;
  4. set<long long> S;
  5. long long frecv[4], v[] = {3,4,5,8,10,12,14,32,57,64};
  6. int main()
  7. {
  8.     for(int i = 0;i<(1<<20);i++)
  9.     {
  10.         for(int j = 0;j<4;j++)
  11.             frecv[j] = 0;
  12.         for(int j = 0;j<10;j++)
  13.         {
  14.             int nrelem = ((i >> (2*j)) % 4);
  15.             frecv[nrelem] += v[j];
  16.         }
  17.         long long P = frecv[1] + frecv[2] + frecv[3];
  18.         bool valid = true;
  19.         for(int j = 0; j < 3 && valid; j++)
  20.         {
  21.             if(P - 2 * frecv[j + 1] <= 0)
  22.                 valid = false;
  23.             if(frecv[j % 3 + 1] >= frecv[(j+1) % 3 + 1] + frecv[(j+2) % 3 + 1])
  24.                 valid = false;
  25.         }
  26.         if(valid)
  27.         {
  28.            long long aria = P * (P - 2*frecv[1]) * (P - 2*frecv[2]) * (P - 2*frecv[3]);
  29.            S.insert(aria);
  30.         }
  31.  
  32.     }
  33.     cout << S.size() << '\n';
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement