Advertisement
a53

douamii22

a53
Jan 1st, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #define N 100000000
  3. using namespace std;
  4.  
  5. int K,i,n,x;
  6.  
  7. int caut(int l, int r)
  8. {
  9. int m = (l+r)/2;
  10. int nr = m/2+m/3+m/337-m/6-m/674-m/1011+m/2022;
  11. if(m-nr==n) return m;
  12. if(m-nr<n) return caut(m+1,r);
  13. return caut(l,m);
  14. }
  15.  
  16. int main()
  17. {
  18. cin >> K;
  19. for(i = 1; i <= K; i++)
  20. {
  21. cin >> n;
  22. x = caut(1,N);
  23. while((x%2==0)or(x%3==0)or(x%337==0))x--;
  24. cout << x << " ";
  25. }
  26. return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement