TAHMID37

4

Oct 12th, 2020 (edited)
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. /*  TAHMID RAHMAN
  2.     DAMIAN FOREVER
  3.      MATH LOVER
  4.     NEVER GIVE UP
  5. */
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define pi acos(-1.0)
  9. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  10. #define ll long long
  11. #define pb push_back
  12. #define fi first
  13. #define se second
  14. #define in insert
  15. #define mp make_pair
  16. #define GCD(a,b) __gcd(a,b);
  17. #define endl "\n"
  18. #define FRU freopen("out.txt","w",stdout)
  19. #define FRO freopen("in.txt","r",stdin)
  20. #define INFLL 9223372036854775807
  21. #define debug 0
  22. #define MAXN   100001
  23. #define ar array
  24. const int mxN=2e5;
  25. const int MOD=1e9+7;
  26. bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  27. {
  28.     return (a.second < b.second);
  29. }
  30. #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
  31. #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
  32. //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
  33. int main()
  34. {
  35.     fastio;
  36.     ll t;
  37.     //t=1;
  38.     cin>>t;
  39.     while(t--)
  40.     {
  41.         ll n,i;
  42.         cin>>n;
  43.         ll ans=0,sum=0;
  44.         ll temp=0;
  45.         while(n>=2)
  46.         {
  47.             if(n==2)
  48.             {
  49.                 ans++;
  50.                 break;
  51.             }
  52.  
  53.             for(i=2; ;i++)
  54.               {
  55.                   if((i*2+i*(i-1)*3*0.5)>n)
  56.                   {
  57.                       i--;
  58.                       temp=i*2+i*(i-1)*3*0.5;
  59.                       ans++;
  60.                       n-=temp;
  61.                       break;
  62.                   }
  63.               }
  64.         }
  65.  
  66.         cout<<ans<<endl;
  67.  
  68.  
  69.     }
  70. }
  71.  
  72.  
  73.  
  74.  
  75.  
Add Comment
Please, Sign In to add comment