結果

問題 No.294 SuperFizzBuzz
ユーザー fmhrfmhr
提出日時 2015-10-25 18:40:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 824 ms / 5,000 ms
コード長 2,546 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 77,292 KB
最終ジャッジ日時 2023-10-11 09:53:27
合計ジャッジ時間 5,803 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,456 KB
testcase_01 AC 77 ms
71,460 KB
testcase_02 AC 73 ms
71,532 KB
testcase_03 AC 73 ms
71,688 KB
testcase_04 AC 73 ms
71,480 KB
testcase_05 AC 71 ms
71,320 KB
testcase_06 AC 93 ms
76,524 KB
testcase_07 AC 110 ms
77,132 KB
testcase_08 AC 446 ms
76,736 KB
testcase_09 AC 750 ms
76,908 KB
testcase_10 AC 748 ms
77,080 KB
testcase_11 AC 166 ms
77,192 KB
testcase_12 AC 478 ms
77,292 KB
testcase_13 AC 570 ms
77,108 KB
testcase_14 AC 824 ms
77,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8

import sys

ume_i=[0, 19, 20, 20, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]

ume_j=[0,75711, 151419, 751427, 302841, 902867, 1502853, 5699, 605701, 1205719, 1805703, 2405735, 3005701, 3605711, 11401, 611385, 1211401, 1811391, 2411421, 3011415, 3611383, 4211407, 4811419, 5411397, 6011395, 6611385, 7211393, 7811395, 22793, 622799, 1222795, 1822785, 2422789, 3022785, 3622775, 4222781, 4822807, 5422785, 6022785, 6622785, 7222771, 7822783, 8422785, 9022791, 9622769, 10222757, 10822781, 11422765, 12022781, 12622791, 13222757, 13822781, 14422783, 15022781, 15622793, 16222799, 45571, 645581, 1245591, 1845571, 2445581, 3045545, 3645561, 4245563, 4845567, 5445567, 6045557, 6645539, 7245557, 7845545, 8445561, 9045557, 9645563, 10245539, 10845557, 11445545, 12045553, 12645561, 13245557, 13845559, 14445575, 15045563, 15645565, 16245553, 16845567, 17445591, 18045541, 18645545, 19245537, 19845569, 20445563, 21045561, 21645557, 22245545, 22845567, 23445569, 24045561, 24645569, 25245579, 25845563, 26445559]


def popcount(x):
	return bin(x).count("1")


#def popcount(n):
#	n = (n & 0x5555555555555555) + ((n & 0xAAAAAAAAAAAAAAAA) >> 1)
#	n = (n & 0x3333333333333333) + ((n & 0xCCCCCCCCCCCCCCCC) >> 2)
#	n = (n & 0x0F0F0F0F0F0F0F0F) + ((n & 0xF0F0F0F0F0F0F0F0) >> 4)
#	n = (n & 0x00FF00FF00FF00FF) + ((n & 0xFF00FF00FF00FF00) >> 8)
#	n = (n & 0x0000FFFF0000FFFF) + ((n & 0xFFFF0000FFFF0000) >> 16)
#	n = (n & 0x00000000FFFFFFFF) + ((n & 0xFFFFFFFF00000000) >> 32) 
#	return n

def solve():
	N = int(input())
	count = 0
	
	# 100000毎にume
#	ume_i = []
#	ume_j = []
#	c = 1000000
	
	p = int(N/100000)

	start_i = ume_i[p]
	start_j = ume_j[p]
	if p!=0:
		count = p*100000-1
	
	x = 0
	for i in range(start_i,26):
		for j in range(start_j,10000000000000):
			a = bin(j)[2:]
			if len(a)>i:
#				print(i,j,a)
				start_j = 0
				break
#			print(a)
			if popcount(j)%3==0 and popcount(j)>=3 and a[-1]=='1':
				count += 1
#				====
#				if count == c:
#					ume_i.append(i)
#					ume_j.append(j)
#					c += 1000000
#				====
				if count==N:
					a = '0'*(i-len(a))+a
					n = a.replace('0', '3').replace('1', '5')
					x = ''.join(n)
					x = int(x)
					print(x)
					sys.exit()

solve()
0