fork(1) download
  1. #include <iostream>
  2. #include<math.h>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. double n, num;
  9. cin >>n;
  10. int cnt = 1;
  11. num = n;
  12. while (num >= 0)
  13. {
  14. if (num == 1)
  15. {
  16. cout << cnt << '\n';
  17. return 0;
  18. }
  19. num -= 6 * cnt;
  20. cnt++;
  21. }
  22. if (fmod(n,6) == 0) cnt--;
  23. cout << cnt << '\n';
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5424KB
stdin
30
stdout
3