結果

問題 No.294 SuperFizzBuzz
ユーザー rlangevin
提出日時 2023-12-27 12:41:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,538 ms / 5,000 ms
コード長 825 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 82,616 KB
実行使用メモリ 255,000 KB
最終ジャッジ日時 2024-09-27 15:28:23
合計ジャッジ時間 11,472 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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