結果

問題 No.1862 Copy and Paste
ユーザー SPD_9X2
提出日時 2022-03-04 22:48:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,179 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 62,728 KB
最終ジャッジ日時 2024-09-13 09:32:40
合計ジャッジ時間 2,525 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

1862:
S = 1 ; T = 0

A: T  = S
B: S += T

Aを行う → Bを複数回行う
の繰り返ししかない

A,B とやると2倍になる
Aの回数は高々30回程度
Aの回数 <= Bの回数

A,Bを行う回数を固定したとき、
序盤にやる方が寄与がでかくなりそう

ABABB -> ( X -> 2X -> 4X -> 6X )
ABBAB -> ( X -> 2X -> 3X -> 6X )

ABABBBB X,2X,4X,6X,8X,10X
ABBBABB X,2X,3X,4X,8X,12X
ABBBBAB X,2X,3X,4X,5X,10X
ABBABBB X,2X,3X,6X,12X,18X

後にやったほうがいいのか
もしかして変化なし?

Aを全探索

"""


import sys
from sys import stdin
from collections import deque

A,B = map(int,stdin.readline().split())
N = int(stdin.readline())

if N == 1:
    print (0)
    sys.exit()

ans = float("inf")

for anum in range(1,35):

    if anum == 1:
        now = A + B * (N-1)
        ans = min(ans , now)
        continue

    now = anum * (A+B)
    nmul = 2 ** anum

    lis = [2] * anum

    ind = 0
    while nmul < N:

        now += B
        nmul //= lis[ind]
        lis[ind] += 1
        nmul *= lis[ind]
        ind = (ind + 1) % anum

        #print (lis,nmul)

    ans = min(ans , now)

    #print (anum,now)

print (ans)
0