-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaekjoon1193.py
More file actions
46 lines (37 loc) · 873 Bytes
/
baekjoon1193.py
File metadata and controls
46 lines (37 loc) · 873 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
x = int(input())
def func(x):
res=1
a=1
b=1
row = 1
if x==1:
return (a,b)
while (res<x):
if row%2==0: #짝수줄
for i in range(row-1):
a+=1
b-=1
res+=1
if(res==x):
return (a,b)
#다음줄로 바뀔때
a+=1
row+=1
res+=1
if(res==x):
return (a,b)
else: # 홀수줄
for i in range(row-1):
a-=1
b+=1
res+=1
if(res==x):
return (a,b)
#다음줄로 바뀔때:
b+=1
row+=1
res+=1
if(res==x):
return (a,b)
fraction = func(x)
print(f'{fraction[0]}/{fraction[1]}')