結果

問題 No.3043 yukicoderへようこそ!
ユーザー finefine
提出日時 2019-04-01 22:11:12
言語 Ruby
(3.2.2)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 11,236 KB
実行使用メモリ 15,268 KB
最終ジャッジ日時 2023-08-18 01:17:54
合計ジャッジ時間 1,193 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,268 KB
testcase_01 AC 87 ms
15,076 KB
testcase_02 AC 82 ms
15,112 KB
testcase_03 AC 82 ms
15,168 KB
testcase_04 AC 82 ms
15,080 KB
testcase_05 AC 81 ms
15,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:21: warning: mismatched indentations at 'end' with 'else' at 9
Syntax OK

ソースコード

diff #

a = $<.map(&:chomp)
if a.size == 1
    if a[0].to_i == 0
        puts "Hello World!"
    else
        n = a[0].to_i
        if n % 2 == 0
            p n * (n + 1) / 2
        else
        1.upto(n) do |x|
            if x % 15 == 0
                puts "FizzBuzz"
            elsif x % 5 == 0
                puts "Buzz"
            elsif x % 3 == 0
                puts "Fizz"
            else
                p x
            end
        end
    end
    end
elsif a.size == 2
    b = a[0].split
    if b.size == 1
        n = b[0].to_i
        p a[1].split.map(&:to_i).inject(:+)
    else
        x, y = b.map(&:to_i)
        puts "#{x + y} #{a[1]}"
    end
else
    n = a[0].to_i
    ans = 0
    1.upto(n) do |i|
        ans += a[i].to_i
    end
    p ans
end
0