結果

問題 No.3043 yukicoderへようこそ!
ユーザー betrue12betrue12
提出日時 2019-04-01 23:56:04
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 15,288 KB
最終ジャッジ日時 2023-08-18 03:34:03
合計ジャッジ時間 1,097 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,256 KB
testcase_01 AC 81 ms
15,088 KB
testcase_02 AC 76 ms
15,248 KB
testcase_03 AC 75 ms
15,052 KB
testcase_04 AC 75 ms
15,288 KB
testcase_05 AC 76 ms
15,044 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 <= 64
            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