結果

問題 No.2117 中国剰余定理入門
ユーザー roarisroaris
提出日時 2022-11-04 22:12:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 263 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 75,852 KB
最終ジャッジ日時 2023-09-26 00:38:43
合計ジャッジ時間 2,658 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,612 KB
testcase_01 AC 70 ms
71,452 KB
testcase_02 AC 68 ms
71,456 KB
testcase_03 AC 70 ms
71,400 KB
testcase_04 AC 74 ms
71,308 KB
testcase_05 AC 71 ms
71,644 KB
testcase_06 AC 68 ms
71,360 KB
testcase_07 AC 71 ms
71,452 KB
testcase_08 AC 71 ms
71,452 KB
testcase_09 AC 69 ms
71,596 KB
testcase_10 AC 75 ms
71,268 KB
testcase_11 AC 70 ms
71,524 KB
testcase_12 AC 69 ms
71,316 KB
testcase_13 AC 73 ms
75,852 KB
testcase_14 AC 70 ms
71,332 KB
testcase_15 AC 74 ms
75,608 KB
testcase_16 AC 72 ms
75,608 KB
testcase_17 AC 75 ms
75,808 KB
testcase_18 AC 75 ms
75,800 KB
testcase_19 AC 71 ms
71,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import *

def lcm(x, y):
    return x*y//gcd(x, y)

B0, C0 = map(int, input().split())
B1, C1 = map(int, input().split())
C0 %= B0
C1 %= B1

for i in range(lcm(B0, B1)):
    if i%B0==C0 and i%B1==C1:
        print(i)
        break
else:
    print('NaN')
0