Tarango

Untitled

Jul 30th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define Size 1000005
  4. #define Mod 1000000007
  5. int N;
  6. int A[Size];
  7. map<int,int> Map;
  8.  
  9. int main() {
  10.     scanf("%d",&N);
  11.     Map.clear();
  12.     for(int i = 0;i<N;i++){
  13.         scanf("%d",&A[i]);
  14.         Map[A[i]] = 1;
  15.     }
  16.     sort(A,A+N);
  17.     int res = 1;
  18.     for(int i = 0;i<N;i++){
  19.         int num = A[i],cnt = 1;
  20.         int cur = num+num,add = num;
  21.         while(cur<Size){
  22.             if(Map.count(cur) == 1){
  23.                 cnt++;
  24.                 add = cur;
  25.             }
  26.             cur += add;;
  27.         }
  28.         res = max(res,cnt);
  29.     }
  30.     cout << res << endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment