artemgf

Игра в перерыве

Jan 12th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5. #include <set>
  6. #include <algorithm>
  7. #include <vector>
  8. #include <stdio.h>
  9. #include <cmath>
  10. #include <math.h>
  11. #include <queue>
  12. #include <stack>
  13. #include <climits>
  14. #include <deque>
  15. #include <ctime>
  16.  
  17. using namespace std;
  18.  
  19. typedef long long ll;
  20. typedef unsigned long long ull;
  21. typedef unsigned int ui;
  22.  
  23. #define mh() make_heap()
  24. #define poph() pop_heap()
  25. #define pushh() push_heap()
  26. #define sor(n) n.begin(), n.end()
  27. #define mp make_pair
  28. #define files freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
  29. #define p(T) pair<T,T>
  30. #define znac(l) abs(l)/l
  31. const ll ok = ll(1e9 + 7);
  32.  
  33. pair<ll,ll> gf(ll a)
  34. {
  35.     ll sc = 0;
  36.     while (a % 2 == 0)
  37.     {
  38.         a /= 2;
  39.         sc++;
  40.     }
  41.     return mp(a, sc);
  42. }
  43.  
  44. int main()
  45. {
  46.     //files;
  47.     ll n;
  48.     cin >> n;
  49.     map<ll, ll> lh;
  50.     ll prom;
  51.     for (int i = 1; i <= n; i++)
  52.     {
  53.         cin >> prom;
  54.         if (prom % 2 != 0)
  55.         {
  56.             lh[prom]++;
  57.         }
  58.         else
  59.         {
  60.             p(ll) k = gf(prom);
  61.             lh[k.first] += pow(2,k.second);
  62.         }
  63.     }
  64.  
  65.     ll max = 0;
  66.     for (auto i = lh.begin(); i != lh.end(); i++)
  67.     {
  68.         ll jo = i->first;
  69.         ll o = i->second;
  70.         if (o != 1)
  71.         {
  72.             while (o != 0)
  73.             {
  74.                 jo *= 2;
  75.                 o /= 2;
  76.                 o -= o % 2;
  77.             }
  78.         }
  79.  
  80.         if (jo >= max)
  81.         {
  82.             max = jo;
  83.         }
  84.     }
  85.  
  86.    
  87.     cout << max;
  88.     return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment