結果

問題 No.294 SuperFizzBuzz
ユーザー roarisroaris
提出日時 2019-12-09 08:29:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 752 bytes
コンパイル時間 844 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 71,528 KB
最終ジャッジ日時 2023-09-02 13:16:02
合計ジャッジ時間 2,770 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,248 KB
testcase_01 AC 70 ms
71,260 KB
testcase_02 AC 70 ms
71,216 KB
testcase_03 AC 70 ms
71,272 KB
testcase_04 AC 70 ms
70,952 KB
testcase_05 AC 72 ms
71,220 KB
testcase_06 AC 72 ms
71,212 KB
testcase_07 AC 73 ms
71,212 KB
testcase_08 AC 74 ms
71,528 KB
testcase_09 AC 72 ms
71,076 KB
testcase_10 AC 72 ms
71,464 KB
testcase_11 AC 73 ms
71,404 KB
testcase_12 AC 72 ms
71,212 KB
testcase_13 AC 72 ms
71,360 KB
testcase_14 AC 72 ms
71,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def C(n, r):
    if r>n:
        return 0
    return fact[n]//fact[r]//fact[n-r]

def F(n):
    res = 0
    
    for i in range(2, n, 3):
        res += C(n-1, i)
    
    return res

def G():
    res = 0
    c = ans.count('5')
    l = len(ans)
    
    if c%3==0:
        s = 2
    elif c%3==1:
        s = 1
    else:
        s = 0
        
    for i in range(s, L-l-1, 3):
        res += C(L-l-2, i)
    
    return res

N = int(input())
fact = [1]

for i in range(1, 30):
    fact.append(fact[-1]*i)

i = 3

while True:
    f = F(i)
    
    if N-f>0:
        N -= f
        i += 1
    else:
        break

L = i
ans = ''

for i in range(L):
    g = G()
    
    if N-g>0:
        ans += '5'
        N -= g
    else:
        ans += '3'

print(ans)
0