結果
問題 | No.294 SuperFizzBuzz |
ユーザー | ciel |
提出日時 | 2015-10-24 00:37:17 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 619 bytes |
コンパイル時間 | 924 ms |
コンパイル使用メモリ | 11,480 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2023-10-11 05:11:03 |
合計ジャッジ時間 | 8,361 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
15,212 KB |
testcase_01 | AC | 88 ms
15,124 KB |
testcase_02 | TLE | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby 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 }