結果

問題 No.294 SuperFizzBuzz
ユーザー cielciel
提出日時 2020-02-08 21:51:31
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 603 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-08 11:32:40
合計ジャッジ時間 33,353 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
16,256 KB
testcase_01 AC 89 ms
16,256 KB
testcase_02 TLE -
testcase_03 AC 87 ms
16,256 KB
testcase_04 AC 85 ms
16,256 KB
testcase_05 AC 86 ms
16,256 KB
testcase_06 AC 86 ms
16,256 KB
testcase_07 AC 87 ms
16,256 KB
testcase_08 AC 354 ms
16,256 KB
testcase_09 AC 3,711 ms
16,256 KB
testcase_10 AC 87 ms
16,256 KB
testcase_11 AC 4,772 ms
16,256 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def comb(n,r)
	if r==0 then return 1 end
	ret=1
	if r>n/2 then r=n-r end
	r.times{|i|
		ret=ret*(n-i)/(i+1)
	}
	return ret
end
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
end

n=gets.to_i
digits=2
loop{
	s=0
	five=2
	while five<=digits
		s+=comb(digits,five)
		five+=3
	end
	break if n<=s
	n-=s
	digits+=1
}
(1..1/0.0).each{|i|
	if popcnt32(i)%3==2
		n-=1
		if n==0
			puts ('%0*b'%[digits,i]).tr('01','35')+'5'
			exit
		end
	end
}
0