結果

問題 No.555 世界史のレポート
ユーザー ckawatakckawatak
提出日時 2019-02-01 07:42:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,082 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 82,616 KB
実行使用メモリ 54,356 KB
最終ジャッジ日時 2024-05-01 06:13:01
合計ジャッジ時間 1,883 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,864 KB
testcase_01 AC 34 ms
53,072 KB
testcase_02 AC 34 ms
52,872 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C,V = list(map(int, input().split(' ')))

def factorize(n):
    i = 2
    nn = n
    factors = {}
    while i * i <= n:
        if nn % i == 0:
            nn /= i
            if i in factors:
                factors[i] = factors[i] + 1
            else:
                factors[i] = 1
        else:
            i = i + 1
                
    if nn != 1:
        nn = int(nn)
        if nn in factors:
            factors[nn] = factors[nn] + 1
        else:
            factors[nn] = 1
            
    return factors
            
def find(n):
    factors = factorize(n)
    
    minimum = float('inf')
    for factor in factors:
        cost = 0
        rest = C + V * ((n // (factor ** factors[factor]))-1)
        if factor % 2 == 1:
            cost = C + V * (factor-1) + rest
        else:
            cost = (C + V) * factors[factor] + rest
        minimum = min(minimum, cost)

    return min(minimum, C + V * (N-1))

minimum = float('inf')
minimum = min(minimum, find(N))
minimum = min(minimum, find(N+1))
minimum = min(minimum, find(N+2))

print(minimum)
0