結果

問題 No.294 SuperFizzBuzz
ユーザー ayaoniayaoni
提出日時 2020-12-05 15:21:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 235 ms / 5,000 ms
コード長 1,619 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 76,508 KB
最終ジャッジ日時 2023-10-13 22:03:07
合計ジャッジ時間 3,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,356 KB
testcase_01 AC 72 ms
71,636 KB
testcase_02 AC 234 ms
76,304 KB
testcase_03 AC 69 ms
71,468 KB
testcase_04 AC 69 ms
71,500 KB
testcase_05 AC 70 ms
71,480 KB
testcase_06 AC 72 ms
71,360 KB
testcase_07 AC 79 ms
76,300 KB
testcase_08 AC 87 ms
76,232 KB
testcase_09 AC 180 ms
76,224 KB
testcase_10 AC 71 ms
71,220 KB
testcase_11 AC 208 ms
76,224 KB
testcase_12 AC 220 ms
76,240 KB
testcase_13 AC 227 ms
76,436 KB
testcase_14 AC 235 ms
76,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import accumulate
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


def popcount(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
    return c


A = [0, 0, 0, 1, 3, 6, 11, 21, 42, 85, 171, 342, 683, 1365, 2730, 5461, 10923, 21846, 43691, 87381, 174762, 349525, 699051, 1398102, 2796203, 5592405]
# A[i] = i桁のSuperFizzBuzzの個数
SA = list(accumulate(A))

N = I()
for i in range(3,26):
    if N <= SA[i]:
        count = 0
        goal = N-SA[i-1]
        for j in range(1<<(i-1)):
            if popcount(j) % 3 == 2:
                count += 1
                if count == goal:
                    ans = j
                    break
        ANS = ''
        for k in range(i-1):
            if (ans>>(i-2-k)) & 1:
                ANS += '5'
            else:
                ANS += '3'
        ANS += '5'
        print(ANS)
        break
0