fork download
  1. #include <iostream>
  2. #include<algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int t;
  7. cin >> t; // Number of games
  8.  
  9. while (t--) {
  10. int n;
  11. cin >> n; // Limit on the position
  12.  
  13. int position = 0; // The initial position of the dot is 0
  14. int i = 1; // To keep track of the moves (1st, 2nd, 3rd, ...)
  15.  
  16. while (true) {
  17. // Sakurako's move (negative direction)
  18. position -= (2 * i - 1);
  19. if (abs(position)>n) { // If the position exceeds -n, Kosuke cannot play
  20. cout << "Sakurako" << endl;
  21. break;
  22. }
  23.  
  24. // Kosuke's move (positive direction)
  25. position += (2 * i -1);
  26. if (abs(position) > n) { // If the position exceeds n, Sakurako cannot play
  27. cout << "Kosuke" << endl;
  28. break;
  29. }
  30.  
  31. i++; // Move to the next turn
  32. }
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5288KB
stdin
4
1
6
3
98
stdout
Sakurako
Sakurako
Sakurako
Sakurako