結果

問題 No.294 SuperFizzBuzz
ユーザー rlangevinrlangevin
提出日時 2023-12-27 12:41:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,647 ms / 5,000 ms
コード長 825 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 254,724 KB
最終ジャッジ日時 2023-12-27 12:41:19
合計ジャッジ時間 12,882 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,588 KB
testcase_01 AC 35 ms
53,588 KB
testcase_02 AC 1,647 ms
249,996 KB
testcase_03 AC 36 ms
53,588 KB
testcase_04 AC 35 ms
53,588 KB
testcase_05 AC 35 ms
53,588 KB
testcase_06 AC 40 ms
59,860 KB
testcase_07 AC 39 ms
59,860 KB
testcase_08 AC 174 ms
88,812 KB
testcase_09 AC 789 ms
254,724 KB
testcase_10 AC 1,571 ms
249,996 KB
testcase_11 AC 1,598 ms
250,000 KB
testcase_12 AC 1,562 ms
250,000 KB
testcase_13 AC 1,565 ms
250,000 KB
testcase_14 AC 1,587 ms
250,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *

N = int(input())
M = 30

comb = [[1] * (M + 1) for _ in range(M)]
for i in range(1, M):
    for j in range(1, i):
        comb[i][j] = comb[i-1][j] + comb[i-1][j-1] 

for i in range(2, M):
    cnt = 0
    for j in range(2, i + 1, 3):
        cnt += comb[i][j]
        
    if N > cnt:
        N -= cnt
    else:
        ans = []
        for j in range(2, M, 3):
            for t in combinations(range(i), j):
                temp = 0
                for p in t:
                    temp |= 1 << p
                ans.append(temp)
        ans.sort()
        ans2 = []
        for n in range(i):
            if (ans[N-1] >> n) & 1:
                ans2.append(5)
            else:
                ans2.append(3)
        ans2.reverse()
        ans2.append(5)
        print(*ans2, sep="")
        exit()
0