結果

問題 No.1352 Three Coins
ユーザー MitarushiMitarushi
提出日時 2021-01-17 14:46:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 76,988 KB
最終ジャッジ日時 2023-08-24 23:05:59
合計ジャッジ時間 5,595 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,412 KB
testcase_01 AC 71 ms
71,368 KB
testcase_02 AC 109 ms
76,680 KB
testcase_03 AC 121 ms
76,716 KB
testcase_04 AC 141 ms
76,812 KB
testcase_05 AC 152 ms
76,856 KB
testcase_06 AC 116 ms
76,988 KB
testcase_07 AC 72 ms
71,516 KB
testcase_08 AC 120 ms
76,932 KB
testcase_09 AC 83 ms
76,708 KB
testcase_10 AC 93 ms
76,564 KB
testcase_11 AC 80 ms
76,684 KB
testcase_12 AC 73 ms
71,484 KB
testcase_13 AC 119 ms
76,636 KB
testcase_14 AC 113 ms
76,676 KB
testcase_15 AC 157 ms
76,652 KB
testcase_16 AC 73 ms
71,372 KB
testcase_17 AC 80 ms
76,512 KB
testcase_18 AC 84 ms
76,748 KB
testcase_19 AC 71 ms
71,480 KB
testcase_20 AC 71 ms
71,572 KB
testcase_21 AC 139 ms
76,692 KB
testcase_22 AC 71 ms
71,184 KB
testcase_23 AC 71 ms
71,344 KB
testcase_24 AC 76 ms
76,172 KB
testcase_25 AC 71 ms
71,580 KB
testcase_26 AC 70 ms
71,608 KB
testcase_27 AC 76 ms
76,112 KB
testcase_28 AC 145 ms
76,796 KB
testcase_29 AC 187 ms
76,644 KB
testcase_30 AC 145 ms
76,684 KB
testcase_31 AC 79 ms
76,076 KB
testcase_32 AC 146 ms
76,780 KB
testcase_33 AC 73 ms
71,484 KB
testcase_34 AC 73 ms
71,672 KB
testcase_35 AC 82 ms
76,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
a, b, c = map(int, input().split())
if gcd(a, gcd(b, c)) != 1:
    print("INF")
    exit()
d = {}
for i in range(c):
    for j in range(c):
        x = i*a+j*b
        if x%c not in d:
            d[x%c] = x
        else:
            d[x % c] = min(x, d[x%c])
ans = 0
for i,j in d.items():
    ans += (j-i)//c
print(ans)
0