結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-01 14:29:48 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 718 ms / 1,000 ms |
| コード長 | 742 bytes |
| コンパイル時間 | 1,186 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 44,904 KB |
| 最終ジャッジ日時 | 2024-12-28 11:54:50 |
| 合計ジャッジ時間 | 24,587 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from math import gcd
import numpy as np
A,B,T = map(int,read().split())
def solve_coprime(A,B,T):
# assume (A,B) == 1
if A * B < T:
return T # できるので
# AB is large. B is large. Bの枚数ごとに何とかする
U = 10 ** 5
b = np.arange(U,dtype=np.int64)
a = np.maximum(0, (T - b * B + A - 1) // A)
x = a * A + b * B
assert (x >= T).all()
return x.min()
def solve(A,B,T):
g = gcd(A,B)
A //= g; B //= g; T = (T + g - 1) // g
return g * solve_coprime(A,B,T)
# solve(50,80,120), solve(123,456,1), solve(1234, 1688, 10000)
answer = solve(A,B,T)
print(answer)
maspy