結果

問題 No.3043 yukicoderへようこそ!
ユーザー betrue12betrue12
提出日時 2019-04-01 23:52:26
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 7,808 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-05-05 09:56:25
合計ジャッジ時間 993 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
12,288 KB
testcase_01 AC 77 ms
12,288 KB
testcase_02 AC 75 ms
12,416 KB
testcase_03 WA -
testcase_04 AC 75 ms
12,416 KB
testcase_05 AC 75 ms
12,160 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