結果

問題 No.347 微分と積分
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-18 01:33:28
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 311 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 11,320 KB
実行使用メモリ 15,668 KB
最終ジャッジ日時 2023-10-11 17:55:06
合計ジャッジ時間 3,068 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,644 KB
testcase_01 AC 77 ms
15,632 KB
testcase_02 AC 78 ms
15,408 KB
testcase_03 AC 77 ms
15,500 KB
testcase_04 AC 78 ms
15,316 KB
testcase_05 AC 78 ms
15,224 KB
testcase_06 AC 77 ms
15,484 KB
testcase_07 AC 77 ms
15,656 KB
testcase_08 AC 77 ms
15,668 KB
testcase_09 AC 78 ms
15,448 KB
testcase_10 AC 78 ms
15,504 KB
testcase_11 AC 77 ms
15,616 KB
testcase_12 AC 76 ms
15,060 KB
testcase_13 AC 78 ms
15,392 KB
testcase_14 AC 78 ms
15,500 KB
testcase_15 AC 77 ms
15,348 KB
testcase_16 AC 78 ms
15,528 KB
testcase_17 AC 77 ms
15,436 KB
testcase_18 AC 79 ms
15,408 KB
testcase_19 AC 79 ms
15,320 KB
testcase_20 AC 77 ms
15,484 KB
testcase_21 AC 77 ms
15,636 KB
testcase_22 AC 77 ms
15,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
b = gets.to_i
a = gets.split.map(&:to_f)
sum1 = 0.0
sum2 = 0.0
n.times do |i|
    if a[i] != 0.0
        sum1 += a[i] * (b ** (a[i] - 1.0))
    end
    if a[i] != -1.0
        sum2 += 1.0 / (a[i] + 1.0) * (b ** (a[i] + 1.0))
    else
        sum2 += Math.log(b.abs)
    end
end
puts sum1
puts sum2
0