artemgf

Длинное условие

Apr 5th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <math.h>
  6. #include <algorithm>
  7. #include <vector>
  8. #include <cmath>
  9. #include <set>
  10.  
  11. using namespace std;
  12.  
  13. int fact(long long n, long long i)
  14. {
  15.     long long prom = 1;
  16.     if (n != 0 && i!=0)
  17.     {
  18.         for (long long j = i; j <= n; j++)
  19.             prom *= j;
  20.     }
  21.     return prom;
  22. }
  23. int main()
  24. {
  25.     long long prom;
  26.     long long sc[4]{ 0,0,0,0 };
  27.     long long n;
  28.  
  29.     cin >> n;
  30.     for (long long i = 1; i <= n; i++)
  31.     {
  32.         cin >> prom;
  33.         sc[prom]++;
  34.     }
  35.     sort(sc + 1, sc + 1 + 3);
  36.     if (n < 6)
  37.     {
  38.         prom = 1;
  39.         for (long long i = 1; i <= 2; i++)
  40.             prom = prom * fact(sc[i], 2);
  41.  
  42.         if (fact(n, sc[3] + 1) >= 6 * prom)
  43.             cout << "Yes";
  44.         else
  45.             cout << "No";
  46.     }
  47.     else
  48.         if (sc[3] == n)
  49.             cout << "No";
  50.         else
  51.             cout << "Yes";
  52.    
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment