Skip to content

Commit 0d490a0

Browse files
committed
Added shortest for kattis forest
1 parent 99380b8 commit 0d490a0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from math import gcd;a,b=map(int,input().split());c=gcd(a,b);a//=c;b//=c;d,e,f,j=map(int,input().split())
2+
d,f=sorted([d,f])
3+
e,j=sorted([e,j])
4+
k=1
5+
while k<c:
6+
x=k*a;y=k*b;k+=1
7+
if d<x<=f and e<=y<=j:k=min(f//a,j//b)+1;continue
8+
print("No\n%d %d"%(x,y));break
9+
else:print("Yes")

0 commit comments

Comments
 (0)