結果

問題 No.144 エラトステネスのざる
ユーザー iwotiwot
提出日時 2020-06-24 14:28:05
言語 Raku
(rakudo v2024.02)
結果
WA  
実行時間 -
コード長 313 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 135,420 KB
実行使用メモリ 185,836 KB
最終ジャッジ日時 2023-09-16 21:06:04
合計ジャッジ時間 13,372 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

my ($n, $p) = get.words;

put $n;
put $p;

put solve($n.Int, $p.Rat);

sub solve(Int $n, Rat $p) {
  my $p2 = 1.0 - $p;
  my @s = gather for 1..$n+1 { take 1.0 };
  my $ans = 0.0;
  for 2..$n -> $i {
    $ans = $ans + @s[$i];
    for $i*2,$i*3...$n -> $j {
      @s[$j] = @s[$j] * $p2;
    }
  }
  return $ans;
}
0