結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-19 00:41:12 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 594 bytes |
| コンパイル時間 | 140 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-10-08 03:21:24 |
| 合計ジャッジ時間 | 2,421 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 2 |
| other | AC * 3 RE * 26 |
ソースコード
import fractions
def read_data():
A, B, T = map(int, input().split())
return A, B, T
def approximate(r, A, B):
result = float('inf')
for bB in range(0, r + B, B):
# bB + a * A >= r
a = max(0, ((r - bB - 1) // A) + 1)
ab = a * A + bB
if ab < result:
result = ab
return result
def solve(A, B, T):
if T <= A:
return A
AB = A * B // fractions.gcd(A, B)
m, r = divmod(T, AB)
return (m - 1) * AB + approximate(r + AB, A, B)
if __name__ == '__main__':
A, B, T = read_data()
print(solve(A, B, T))