結果
| 問題 | No.1352 Three Coins | 
| コンテスト | |
| ユーザー |  lam6er | 
| 提出日時 | 2025-04-16 15:44:05 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 472 ms / 2,000 ms | 
| コード長 | 1,093 bytes | 
| コンパイル時間 | 412 ms | 
| コンパイル使用メモリ | 81,824 KB | 
| 実行使用メモリ | 235,032 KB | 
| 最終ジャッジ日時 | 2025-04-16 15:47:02 | 
| 合計ジャッジ時間 | 3,556 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 34 | 
ソースコード
import sys
import math
def main():
    A, B, C = map(int, sys.stdin.readline().split())
    a, b, c = A, B, C
    # Compute gcd of three numbers
    d = math.gcd(math.gcd(a, b), c)
    if d != 1:
        print("INF")
        return
    m = min(a, b, c)
    reachable = {0}
    current_max = 0
    current_streak = 0
    required_streak = m
    i = 1
    while True:
        if (i - a in reachable) or (i - b in reachable) or (i - c in reachable):
            reachable.add(i)
            if i == current_max + 1:
                current_streak += 1
                current_max = i
                if current_streak == required_streak:
                    break
            else:
                current_streak = 1
                current_max = i
                if current_streak == required_streak:
                    break
        else:
            current_streak = 0
        i += 1
    upper_limit = current_max - m
    count = 0
    for num in range(1, upper_limit + 1):
        if num not in reachable:
            count += 1
    print(count)
if __name__ == "__main__":
    main()
            
            
            
        