結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 323 ms
7,796 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 610 ms
7,864 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 15 ms
7,924 KB
testcase_17 AC 14 ms
7,932 KB
testcase_18 WA -
testcase_19 AC 381 ms
7,908 KB
testcase_20 AC 122 ms
7,816 KB
testcase_21 AC 331 ms
7,852 KB
testcase_22 AC 366 ms
7,852 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=0
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:
      print(d*y3//gcd(d,y3))
    else:
      print(ans)
  else:
    print(-1)
0