結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2015-12-09 00:26:04 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 92 ms / 1,000 ms |
コード長 | 364 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-11-21 11:21:48 |
合計ジャッジ時間 | 4,560 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
コンパイルメッセージ
Main.rb:9: warning: assigned but unused variable - items_sum Syntax OK
ソースコード
#!/usr/bin/ruby#reduce(:*)ではなくreduce(:lcm)を使う以外はCodeIQ q1560を流用def solve(factor,ma)r=0(1..factor.size).each{|n|factor.combination(n){|a|divisor=a.reduce(:lcm)items=ma/divisoritems_sum=items*(items+1)/2r+=(-1)**(~n%2) * items # _sum*divisor}}rendm=gets.to_ifactor=gets.split.map(&:to_i)p solve(factor,m)