Advertisement
Tkap1

Untitled

Jan 21st, 2024 (edited)
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4.  
  5. int main(int argc, char** argv)
  6. {
  7.     int count;
  8.     scanf("%d", &count);
  9.     for(int i = 0; i < count; i++) {
  10.         int balls;
  11.         scanf("%d", &balls);
  12.  
  13.         int size = 1;
  14.         int steps = 0;
  15.         while(balls >= size) {
  16.             balls -= size;
  17.             size += steps + 2;
  18.             steps += 1;
  19.         }
  20.         printf("%i\n", steps);
  21.     }
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement