Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define Size 1000005
- #define Mod 1000000007
- int N;
- int A[Size];
- map<int,int> Map;
- int main() {
- scanf("%d",&N);
- Map.clear();
- for(int i = 0;i<N;i++){
- scanf("%d",&A[i]);
- Map[A[i]] = 1;
- }
- sort(A,A+N);
- int res = 1;
- for(int i = 0;i<N;i++){
- int num = A[i],cnt = 1;
- int cur = num+num,add = num;
- while(cur<Size){
- if(Map.count(cur) == 1){
- cnt++;
- add = cur;
- }
- cur += add;;
- }
- res = max(res,cnt);
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment