結果

問題 No.1352 Three Coins
ユーザー MitarushiMitarushi
提出日時 2021-01-17 14:46:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 63,104 KB
最終ジャッジ日時 2024-12-23 09:35:52
合計ジャッジ時間 3,935 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

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