結果

問題 No.294 SuperFizzBuzz
ユーザー cielciel
提出日時 2015-10-24 00:43:23
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 173 ms / 5,000 ms
コード長 752 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 77,960 KB
実行使用メモリ 78,900 KB
最終ジャッジ日時 2023-10-11 05:11:55
合計ジャッジ時間 4,338 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
76,320 KB
testcase_01 AC 76 ms
76,396 KB
testcase_02 AC 173 ms
78,656 KB
testcase_03 AC 73 ms
76,428 KB
testcase_04 AC 74 ms
76,428 KB
testcase_05 AC 74 ms
76,596 KB
testcase_06 AC 76 ms
76,248 KB
testcase_07 AC 81 ms
78,860 KB
testcase_08 AC 87 ms
78,780 KB
testcase_09 AC 137 ms
78,900 KB
testcase_10 AC 75 ms
76,636 KB
testcase_11 AC 155 ms
78,680 KB
testcase_12 AC 162 ms
78,524 KB
testcase_13 AC 167 ms
78,684 KB
testcase_14 AC 172 ms
78,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
def comb(n,r):
	if r==0: return 1
	ret=1
	if r>n//2: r=n-r
	for i in range(r):
		ret=ret*(n-i)/(i+1)
	return ret

def popcnt32(n):
	m1=0x55555555
	m2=0x33333333
	m4=0x0f0f0f0f
	m8=0x00ff00ff
	m16=0x0000ffff
	n=((n>>1)&m1)+(n&m1)
	n=((n>>2)&m2)+(n&m2)
	n=((n>>4)&m4)+(n&m4)
	n=((n>>8)&m8)+(n&m8)
	n=((n>>16)&m16)+(n&m16)
	return n

if 'maketrans' in str.__dict__:
	maketrans=str.maketrans
	raw_input=input
else:
	from string import maketrans

n=int(raw_input())
digits=2
while True:
	s=0
	five=2
	while five<=digits:
		s+=comb(digits,five)
		five+=3
	if n<=s: break
	n-=s
	digits+=1

i=1
while True:
	if popcnt32(i)%3==2:
		n-=1
		if n==0:
			print(('{:0'+str(digits)+'b}').format(i).translate(maketrans('01','35'))+'5')
			break
	i+=1
0