結果
| 問題 |
No.294 SuperFizzBuzz
|
| コンテスト | |
| ユーザー |
ayaoni
|
| 提出日時 | 2020-12-05 15:21:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 205 ms / 5,000 ms |
| コード長 | 1,619 bytes |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 82,144 KB |
| 実行使用メモリ | 62,416 KB |
| 最終ジャッジ日時 | 2024-09-15 17:44:29 |
| 合計ジャッジ時間 | 2,551 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
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
ayaoni