Skip to content

Commit 4aa0e5c

Browse files
committed
Create 337B - Routine Problem.py
1 parent c26af31 commit 4aa0e5c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

337B - Routine Problem.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#4302271 Aug 17, 2013 12:41:50 PM fuwutu 337B - Routine Problem Python 3 Accepted 92 ms 0 KB
2+
def gcd(a, b):
3+
while a % b != 0:
4+
a, b = b, a % b
5+
return b
6+
7+
l = input().split(' ')
8+
a, b, c, d = int(l[0]), int(l[1]), int(l[2]), int(l[3])
9+
if a * d > b * c:
10+
p = a * d - b * c
11+
q = a * d
12+
else:
13+
p = b * c - a * d
14+
q = b * c
15+
e = gcd(p, q)
16+
p //= e
17+
q //= e
18+
print(str(p) + "/" + str(q))

0 commit comments

Comments
 (0)