結果

問題 No.186 中華風 (Easy)
ユーザー takakintakakin
提出日時 2020-06-22 00:13:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 767 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2023-09-27 01:00:19
合計ジャッジ時間 8,255 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
7,712 KB
testcase_01 AC 160 ms
7,780 KB
testcase_02 AC 154 ms
7,888 KB
testcase_03 AC 18 ms
7,720 KB
testcase_04 AC 347 ms
7,892 KB
testcase_05 AC 335 ms
7,752 KB
testcase_06 AC 514 ms
7,760 KB
testcase_07 AC 383 ms
7,880 KB
testcase_08 AC 610 ms
7,748 KB
testcase_09 AC 610 ms
7,788 KB
testcase_10 AC 488 ms
7,772 KB
testcase_11 AC 767 ms
7,820 KB
testcase_12 AC 191 ms
7,756 KB
testcase_13 AC 232 ms
7,756 KB
testcase_14 AC 269 ms
7,716 KB
testcase_15 AC 41 ms
7,788 KB
testcase_16 AC 15 ms
7,880 KB
testcase_17 AC 14 ms
7,708 KB
testcase_18 AC 93 ms
7,872 KB
testcase_19 AC 375 ms
7,684 KB
testcase_20 AC 123 ms
7,804 KB
testcase_21 AC 329 ms
7,712 KB
testcase_22 AC 356 ms
7,756 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:
      print(d*y3//gcd(d,y3))
    else:
      print(ans)
  else:
    print(-1)
0