Advertisement
jakaria_hossain

codeforces - card constructions

May 7th, 2020
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
  5. ll cnt =0;
  6. ll count_piramid(ll n)
  7. {
  8.     if(n<2)
  9.         return cnt;
  10.     ll x=0,i=1;
  11.     while(x<n)
  12.     {
  13.         x+=i*2+i-1;
  14.         i++;
  15.     }
  16.     cnt++;
  17.     //cout<<cnt<< " "<<n<<" "<<x<<endl;
  18.     if(x>n)
  19.     {
  20.         i--;
  21.         x-=i*2+i-1;
  22.         n-=x;
  23.         //cout<<x<<" Test "<<n<<endl;
  24.         count_piramid(n);
  25.     }
  26.     return cnt;
  27. }
  28. int main()
  29. {
  30.     fast()
  31.     ll t ;
  32.     cin>>t;
  33.     while(t--)
  34.     {
  35.         ll n,i=1,x=0;
  36.         cnt=0;
  37.         cin>>n;
  38.         cout<<count_piramid(n)<<endl;
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement