Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define N 100000000
- using namespace std;
- int K,i,n,x;
- int caut(int l, int r)
- {
- int m = (l+r)/2;
- int nr = m/2+m/3+m/337-m/6-m/674-m/1011+m/2022;
- if(m-nr==n) return m;
- if(m-nr<n) return caut(m+1,r);
- return caut(l,m);
- }
- int main()
- {
- cin >> K;
- for(i = 1; i <= K; i++)
- {
- cin >> n;
- x = caut(1,N);
- while((x%2==0)or(x%3==0)or(x%337==0))x--;
- cout << x << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement