結果

問題 No.1352 Three Coins
コンテスト
ユーザー Mitarushi
提出日時 2021-01-17 14:46:52
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 106 ms / 2,000 ms
+ 669µs
コード長 341 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 86 ms
コンパイル使用メモリ 82,752 KB
実行使用メモリ 66,644 KB
最終ジャッジ日時 2026-10-10 13:46:35
合計ジャッジ時間 3,087 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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