-
Notifications
You must be signed in to change notification settings - Fork 31
/
solution.py
31 lines (30 loc) · 1.05 KB
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# حلزون مختصاتی
# https://quera.ir/problemset/597/
n = int(input())
counter = 1
prior_pos = []
current_pos = [0, 0]
if n == 1:
print(0, 0)
else:
while counter < n:
if current_pos[0] > 0 and current_pos[1] < 0:
# prior_pos = current_pos.copy()
current_pos[1] = -current_pos[1] + 1
elif current_pos[0] > 0 and current_pos[1] > 0:
# prior_pos = current_pos.copy()
current_pos[0] = -current_pos[0]
elif current_pos[0] < 0 and current_pos[1] > 0:
# prior_pos = current_pos.copy()
current_pos[1] = -current_pos[1]
elif current_pos[0] < 0 and current_pos[1] < 0:
# prior_pos = current_pos.copy()
current_pos[0] = -current_pos[0] + 1
elif current_pos[0] == 0 and current_pos[1] == 0:
current_pos[0] = 1
current_pos[1] = 0
elif current_pos[0] == 1 and current_pos[1] == 0:
current_pos[0] = 1
current_pos[1] = 1
counter += 1
print(current_pos[0], current_pos[1])