結果

問題 No.186 中華風 (Easy)
ユーザー takakintakakin
提出日時 2020-06-22 00:13:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 575 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 7,996 KB
最終ジャッジ日時 2023-09-16 18:58:42
合計ジャッジ時間 8,311 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 301 ms
7,756 KB
testcase_01 AC 155 ms
7,808 KB
testcase_02 AC 152 ms
7,748 KB
testcase_03 AC 17 ms
7,904 KB
testcase_04 AC 345 ms
7,792 KB
testcase_05 AC 328 ms
7,860 KB
testcase_06 AC 463 ms
7,764 KB
testcase_07 AC 394 ms
7,824 KB
testcase_08 AC 570 ms
7,848 KB
testcase_09 AC 572 ms
7,924 KB
testcase_10 AC 471 ms
7,992 KB
testcase_11 AC 727 ms
7,924 KB
testcase_12 AC 185 ms
7,908 KB
testcase_13 AC 233 ms
7,988 KB
testcase_14 AC 268 ms
7,804 KB
testcase_15 AC 45 ms
7,996 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 93 ms
7,856 KB
testcase_19 AC 360 ms
7,848 KB
testcase_20 AC 114 ms
7,844 KB
testcase_21 AC 320 ms
7,800 KB
testcase_22 AC 348 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
ans=x1
ct=0
chk=False
while ct<y2:
  if ans%y2==x2:
    chk=True
    break
  else:
    ans+=y1
    ct+=1
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
if chk==False:
  print(-1)
else:
  chk=False
  ct=0
  d=y1*y2//gcd(y1,y2)
  while ct<y3:
    if ans%y3==x3:
      chk=True
      break
    else:
      ans+=d
      ct+=1
  if chk:
    if ans==0:
      prnt(d*y3//gcd(d,y3))
    else:
      print(ans)
  else:
    print(-1)
0