結果

問題 No.1271 初めての級数
ユーザー simansiman
提出日時 2021-08-04 04:41:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 158 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 15,484 KB
最終ジャッジ日時 2023-10-14 21:12:43
合計ジャッジ時間 2,352 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,236 KB
testcase_01 AC 78 ms
15,296 KB
testcase_02 AC 77 ms
15,020 KB
testcase_03 AC 89 ms
15,484 KB
testcase_04 AC 80 ms
15,480 KB
testcase_05 AC 78 ms
15,256 KB
testcase_06 AC 78 ms
15,164 KB
testcase_07 AC 77 ms
15,400 KB
testcase_08 AC 77 ms
15,320 KB
testcase_09 AC 77 ms
15,464 KB
testcase_10 AC 77 ms
15,152 KB
testcase_11 AC 77 ms
15,268 KB
testcase_12 AC 77 ms
15,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

K = gets.to_i

if K == 0
  puts Rational(Math::PI ** 2, 6).to_f
else
  ans = 0

  1.upto(K) do |n|
    ans += Rational(1, n)
  end

  puts (ans / K).to_f
end
0