結果

問題 No.639 An Ordinary Sequence
ユーザー chineristACchineristAC
提出日時 2020-04-06 03:23:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,437 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 88,116 KB
最終ジャッジ日時 2023-09-18 13:26:14
合計ジャッジ時間 4,683 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from collections import defaultdict
import heapq

ansmin={2: 1, 3: 3, 4: 5, 5: 9, 7: 15, 8: 25, 9: 27, 12: 45, 15: 75, 16: 81, 17: 125, 21: 135, 27: 225, 28: 243, 32: 375, 37: 405, 38: 625, 48: 675, 49: 729, 59: 1125, 65: 1215, 70: 1875, 85: 2025, 86: 2187, 87: 3125, 107: 3375, 114: 3645, 129: 5625, 150: 6075, 151: 6561, 157: 9375, 192: 10125, 200: 10935, 201: 15625, 236: 16875, 264: 18225, 265: 19683, 286: 28125, 342: 30375, 351: 32805, 358: 46875, 428: 50625, 464: 54675, 465: 59049, 466: 78125, 522: 84375, 606: 91125, 616: 98415}
ansmax= {2: 2, 3: 4, 4: 8, 5: 14, 7: 24, 8: 26, 9: 44, 12: 74, 15: 80, 16: 124, 17: 134, 21: 224, 27: 242, 28: 374, 32: 404, 37: 624, 38: 674, 48: 728, 49: 1124, 59: 1214, 65: 1874, 70: 2024, 85: 2186, 86: 3124, 87: 3374, 107: 3644, 114: 5624, 129: 6074, 150: 6560, 151: 9374, 157: 10124, 192: 10934, 200: 15624, 201: 16874, 236: 18224, 264: 19682, 265: 28124, 286: 30374, 342: 32804, 351: 46874, 358: 50624, 428: 54674, 464: 59048, 465: 78124, 466: 84374, 522: 91124, 606: 98414, 616: 100000}

ans=[0 for i in range(0,100001)]
for key in ansmin.keys():
    a=ansmin[key]
    b=ansmax[key]
    for j in range(a,b+1):
        ans[j]=key

ans[0]=1

N=int(input())
q=[N]
count=0
while q:
    x=heapq.heappop(q)
    p=x//3
    r=x//5
    if 100000>=p:
        count+=ans[p]
    else:
        heapq.heappush(q,p)
    if 100000>=r:
        count+=ans[r]
    else:
        heapq.heappush(q,r)

print(count)
0