Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
- ll cnt =0;
- ll count_piramid(ll n)
- {
- if(n<2)
- return cnt;
- ll x=0,i=1;
- while(x<n)
- {
- x+=i*2+i-1;
- i++;
- }
- cnt++;
- //cout<<cnt<< " "<<n<<" "<<x<<endl;
- if(x>n)
- {
- i--;
- x-=i*2+i-1;
- n-=x;
- //cout<<x<<" Test "<<n<<endl;
- count_piramid(n);
- }
- return cnt;
- }
- int main()
- {
- fast()
- ll t ;
- cin>>t;
- while(t--)
- {
- ll n,i=1,x=0;
- cnt=0;
- cin>>n;
- cout<<count_piramid(n)<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement