fork download
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. main(){
  6. int n;
  7. cin >> n;
  8.  
  9. int count = 1;
  10. int d = 1;
  11. while (n >= d) {
  12. n -= d;
  13. count++;
  14. d += count;
  15. }
  16.  
  17. cout << count - 1 << endl;
  18. }
  19.  
Success #stdin #stdout 0s 5276KB
stdin
4
stdout
2