結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-01-26 15:37:44 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,244 bytes |
| コンパイル時間 | 410 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 210,788 KB |
| 最終ジャッジ日時 | 2024-09-14 11:04:29 |
| 合計ジャッジ時間 | 4,755 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 28 |
ソースコード
import sys
sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]
def gcd(a,b):
while b:a,b=b,a%b
return a
def main():
a,b,t=MI()
g=gcd(a,b)
if t>=a*b//g:
ans=(t+g-1)//g
else:
hp=[]
fin=set()
heappush(hp,0)
while 1:
x=heappop(hp)
if x>=t:
ans=x
break
if x+a not in fin:
heappush(hp,x+a)
fin.add(x+a)
if x+b not in fin:
heappush(hp,x+b)
fin.add(x+b)
print(ans)
main()
mkawa2