結果

問題 No.144 エラトステネスのざる
ユーザー code-devocode-devo
提出日時 2016-01-19 17:07:28
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 264 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 65,540 KB
最終ジャッジ日時 2023-10-21 06:53:50
合計ジャッジ時間 15,420 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
16,100 KB
testcase_01 AC 84 ms
16,152 KB
testcase_02 AC 74 ms
16,152 KB
testcase_03 AC 72 ms
16,100 KB
testcase_04 AC 72 ms
16,100 KB
testcase_05 AC 76 ms
16,100 KB
testcase_06 AC 80 ms
16,196 KB
testcase_07 AC 79 ms
16,200 KB
testcase_08 AC 76 ms
16,196 KB
testcase_09 AC 76 ms
16,196 KB
testcase_10 AC 74 ms
16,196 KB
testcase_11 AC 80 ms
16,204 KB
testcase_12 AC 76 ms
16,144 KB
testcase_13 AC 1,587 ms
61,252 KB
testcase_14 AC 1,548 ms
61,252 KB
testcase_15 AC 1,604 ms
61,252 KB
testcase_16 AC 1,572 ms
61,252 KB
testcase_17 AC 1,618 ms
61,252 KB
testcase_18 AC 1,751 ms
65,040 KB
testcase_19 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

SS = gets.split
N = SS[0].to_i
P = SS[1].to_f

A = Array.new(N + 1, -1)
for n in 2..N do
  m = n
  while m <= N do
    A[m] += 1
    m += n
  end
end

sum = 0

TBL = {}
for n in 2..N do
  p = TBL[n]
  TBL[n] = p = (1 - P) ** A[n] unless p
  sum += p
end

puts sum
0