結果

問題 No.3043 yukicoderへようこそ!
ユーザー betrue12betrue12
提出日時 2019-04-01 23:54:06
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-05-05 10:01:18
合計ジャッジ時間 1,223 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,032 KB
testcase_01 WA -
testcase_02 AC 93 ms
12,032 KB
testcase_03 AC 88 ms
12,288 KB
testcase_04 AC 88 ms
12,160 KB
testcase_05 AC 91 ms
12,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def fizzbuzz(n)
    (1..n).each do |i|
        if i%15 == 0
            puts "FizzBuzz"
        elsif i%3 == 0
            puts "Fizz"
        elsif i%5 == 0
            puts "Buzz"
        else
            puts i
        end
    end
end

begin
    ns = gets.chomp
    if ns.include?(' ')
        ab = ns.split.map(&:to_i).inject(:+)
        s = gets.chomp
        puts "#{ab} #{s}"
        exit
    end

    N = ns.to_i
    lines = readlines
    if lines.size == 0
        if N <= 16
            fizzbuzz(N)
        else
            puts N*(N+1)/2
        end
    elsif lines.size == 1
        puts lines[0].split.map(&:to_i).inject(:+)
    else
        puts lines.map(&:to_i).inject(:+)
    end

rescue
    puts "Hello World!"
end
0