結果

問題 No.347 微分と積分
ユーザー simansiman
提出日時 2022-10-25 10:42:28
言語 Ruby
(3.3.0)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 328 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 11,368 KB
実行使用メモリ 15,680 KB
最終ジャッジ日時 2023-09-16 09:44:23
合計ジャッジ時間 3,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,552 KB
testcase_01 AC 81 ms
15,544 KB
testcase_02 AC 80 ms
15,508 KB
testcase_03 AC 81 ms
15,376 KB
testcase_04 AC 79 ms
15,232 KB
testcase_05 AC 80 ms
15,184 KB
testcase_06 AC 80 ms
15,624 KB
testcase_07 AC 79 ms
15,352 KB
testcase_08 AC 79 ms
15,420 KB
testcase_09 AC 80 ms
15,620 KB
testcase_10 AC 82 ms
15,416 KB
testcase_11 AC 80 ms
15,352 KB
testcase_12 AC 80 ms
15,076 KB
testcase_13 AC 81 ms
15,636 KB
testcase_14 AC 81 ms
15,352 KB
testcase_15 AC 80 ms
15,480 KB
testcase_16 AC 81 ms
15,368 KB
testcase_17 AC 82 ms
15,680 KB
testcase_18 AC 82 ms
15,476 KB
testcase_19 AC 82 ms
15,048 KB
testcase_20 AC 81 ms
15,516 KB
testcase_21 AC 81 ms
15,544 KB
testcase_22 AC 81 ms
15,420 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
B = gets.to_i
A = gets.split.map(&:to_f)

def f
  val = 0

  A.each do |a|
    val += a * B.pow(a - 1)
  end

  val
end

def g
  val = 0

  A.each do |a|
    if a == -1
      val += Math.log(B)
    else
      val += Rational(1, a + 1) * B.pow(a + 1)
    end
  end

  val
end

puts "%.12f" % f()
puts "%.12f" % g()
0