From 7259150d65371a8a1d83beb275546934f5b8d3ab Mon Sep 17 00:00:00 2001 From: bhavana679 Date: Thu, 24 Oct 2024 22:05:02 +0530 Subject: [PATCH] Create python code This is the logical question written in python language. --- python code | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 python code diff --git a/python code b/python code new file mode 100644 index 00000000..543a9143 --- /dev/null +++ b/python code @@ -0,0 +1,64 @@ +Sakurako and Kosuke decided to play some games with a dot on a coordinate line. The dot is currently located in position ๐‘ฅ=0 +. They will be taking turns, and Sakurako will be the one to start. + +On the ๐‘– +-th move, the current player will move the dot in some direction by 2โ‹…๐‘–โˆ’1 + units. Sakurako will always be moving the dot in the negative direction, whereas Kosuke will always move it in the positive direction. + +In other words, the following will happen: + +Sakurako will change the position of the dot by โˆ’1 +, ๐‘ฅ=โˆ’1 + now +Kosuke will change the position of the dot by 3 +, ๐‘ฅ=2 + now +Sakurako will change the position of the dot by โˆ’5 +, ๐‘ฅ=โˆ’3 + now +โ‹ฏ +They will keep on playing while the absolute value of the coordinate of the dot does not exceed ๐‘› +. More formally, the game continues while โˆ’๐‘›โ‰ค๐‘ฅโ‰ค๐‘› +. It can be proven that the game will always end. + +Your task is to determine who will be the one who makes the last turn. + +Input +The first line contains one integer ๐‘ก + (1โ‰ค๐‘กโ‰ค100 +) โ€” the number of games that Sakurako and Kosuke played. + +Each game is described by one number ๐‘› + (1โ‰ค๐‘›โ‰ค100 +) โ€” the number that defines the condition when the game ends. + +Output +For each of the ๐‘ก + games, output a line with the result of that game. If Sakurako makes the last turn, output "Sakurako" (without quotes); else output "Kosuke". + +Example +InputCopy +4 +1 +6 +3 +98 +OutputCopy +Kosuke +Sakurako +Kosuke +Sakurako +#python code: +t = int(input()) +for i in range(t): + n = int(input()) + x = 0 + for j in range(1,n+1): + if j % 2 == 1: + x -= (2 * j - 1) + else: + x = (2 * j - 1) + if x >= 0: + print("Sakurako") + else: + print("Kosuke")