fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7. int n, a = 0;
  8. cin >> n;
  9. int i = 1;
  10. while(1){
  11. if(i * i > n){
  12. n = n - (i - 1)*(i - 1);
  13. i = 0;
  14. a += 1;
  15. }
  16. if(n == 0)
  17. break;
  18. i += 1;
  19. }
  20. cout << a;
  21. }
Success #stdin #stdout 0s 4552KB
stdin
100000
stdout
2