fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define double long double
  4. #define fi first
  5. #define se second
  6. #define endl "\n"
  7. #define ii pair<int,int>
  8. using namespace std;
  9. const int mod=998244353;
  10. const int N=3e5+5;
  11. int sum(int n){
  12. int ans=n*(n+1)*(2*n+1)/6;
  13. return ans;
  14. }
  15. signed main(){
  16. cin.tie(0) -> sync_with_stdio(false);
  17. freopen("BAI4.INP","r",stdin);
  18. freopen("BAI4.OUT","w",stdout);
  19. int q; cin >> q;
  20. while (q--){
  21. int n; cin >> n;
  22. int l=1,r=1500000;
  23. int ans=0;
  24. while(l<=r){
  25. int m=(l+r)/2;
  26. if (sum(m)<=n){
  27. ans=max(ans,m);
  28. l=m+1;
  29. }
  30. else {
  31. r=m-1;
  32. }
  33. }
  34. cout << ans << " ";
  35. }
  36. return 0;
  37. }
  38. // đứng ở dưới thì code mạnh tay lên ai sợ thì đi về
  39. // phong cách phong cách
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty