492A. Vanya and Cubes

  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;
  6. int s=0;
  7. int sum=0;
  8. int cube=0;
  9. cin>>n;
  10. for(int j=1;j<=n;j++)
  11. {
  12. sum =sum +j;
  13. s=sum+s;
  14. if(s>n) break;
  15. cube++;
  16. }
  17. cout<<cube;
  18. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution