Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, lvl = 0;
  8. long long int sum;
  9. cin >> n >> sum;
  10. if(n == 1)
  11. { int it = 1;
  12. while(sum > 0)
  13. {
  14. sum -= (it * it);
  15. it++;
  16. if(sum >= 0) lvl++;
  17. }
  18. }
  19. else
  20. {
  21. int it = 1;
  22. while(sum > 0)
  23. {
  24. sum -= (it * it);
  25. it += 2;
  26. if(sum >= 0) lvl++;
  27. }
  28. }
  29. cout << lvl << endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement