結果

問題 No.1352 Three Coins
コンテスト
ユーザー Mitarushi
提出日時 2021-01-17 14:46:52
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 341 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 153 ms
コンパイル使用メモリ 85,760 KB
実行使用メモリ 64,000 KB
最終ジャッジ日時 2026-05-29 10:40:20
合計ジャッジ時間 2,864 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

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