結果

問題 No.186 中華風 (Easy)
ユーザー pluto77
提出日時 2016-04-14 14:57:04
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 423 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 76,176 KB
実行使用メモリ 77,824 KB
最終ジャッジ日時 2024-07-19 18:27:47
合計ジャッジ時間 4,947 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
#yuki_186
import sys

def gcd(a, b):
 while b:
  a, b = b, a%b
 return a

def lcm(a,b):
 return a/gcd(a,b)*b


x1,y1=map(int,raw_input().split())
x2,y2=map(int,raw_input().split())
x3,y3=map(int,raw_input().split())

for i in xrange(y2):
 a0=y1*i+x1
 if a0==0:
  continue
 if (a0-x2)%y2==0:
  for j in xrange(y3):
   res=a0+j*lcm(y1,y2)
   if (res-x3)%y3==0:
    print res
    sys.exit()
 
print -1
0