結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー yuruhiyayuruhiya
提出日時 2020-04-29 22:14:14
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 666 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 15,348 KB
最終ジャッジ日時 2023-09-25 16:22:40
合計ジャッジ時間 4,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,128 KB
testcase_01 AC 82 ms
15,184 KB
testcase_02 AC 85 ms
15,128 KB
testcase_03 AC 86 ms
15,300 KB
testcase_04 AC 86 ms
15,056 KB
testcase_05 AC 83 ms
15,184 KB
testcase_06 AC 84 ms
15,088 KB
testcase_07 AC 85 ms
15,128 KB
testcase_08 AC 84 ms
15,268 KB
testcase_09 AC 84 ms
15,304 KB
testcase_10 WA -
testcase_11 AC 82 ms
15,184 KB
testcase_12 AC 83 ms
15,092 KB
testcase_13 AC 82 ms
15,252 KB
testcase_14 AC 82 ms
15,268 KB
testcase_15 AC 84 ms
15,348 KB
testcase_16 AC 82 ms
15,040 KB
testcase_17 AC 83 ms
15,308 KB
testcase_18 AC 84 ms
15,064 KB
testcase_19 AC 82 ms
15,124 KB
testcase_20 AC 83 ms
15,040 KB
testcase_21 AC 83 ms
15,112 KB
testcase_22 AC 82 ms
15,044 KB
testcase_23 AC 86 ms
15,040 KB
testcase_24 AC 83 ms
15,268 KB
testcase_25 AC 83 ms
15,132 KB
testcase_26 AC 83 ms
15,128 KB
testcase_27 AC 82 ms
15,164 KB
testcase_28 AC 82 ms
15,300 KB
testcase_29 AC 83 ms
15,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

ans = 0
gets.to_i.times do |i|
    s = gets.chomp
    neg = false
    num = 0
    if s[0] == '-'
        neg = true
        s = s[1...s.size]
    end

    if s.include?('.')
        pos = s.index('.')
        a = s[0...pos]
        b = s[pos + 1...s.size]
        b += "0" * (10 - b.size)
        num = a.to_i * (10 ** 10) + b.to_i
    else
        num = s.to_i * (10 ** 10)
    end

    if neg
        ans -= num
    else
        ans += num
    end
end

if ans == 0
    puts "0.0000000000"
else
    ans = ans.to_s
    if ans.chars.count {|c| c != '-' } == 10
        ans.insert(ans[0] == '-' ? 1 : 0, '0')
    end
    ans.insert(ans.size - 10, '.')
    puts ans
end
0