結果

問題 No.144 エラトステネスのざる
ユーザー iwotiwot
提出日時 2020-06-24 14:29:07
言語 Raku
(rakudo v2024.02)
結果
TLE  
実行時間 -
コード長 296 bytes
コンパイル時間 1,064 ms
コンパイル使用メモリ 127,824 KB
実行使用メモリ 212,568 KB
最終ジャッジ日時 2023-09-16 21:05:39
合計ジャッジ時間 12,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 438 ms
137,188 KB
testcase_01 AC 446 ms
132,816 KB
testcase_02 AC 447 ms
132,820 KB
testcase_03 AC 440 ms
132,816 KB
testcase_04 AC 439 ms
132,872 KB
testcase_05 AC 446 ms
132,756 KB
testcase_06 AC 677 ms
143,132 KB
testcase_07 AC 694 ms
143,660 KB
testcase_08 AC 671 ms
143,416 KB
testcase_09 AC 662 ms
142,568 KB
testcase_10 AC 683 ms
143,596 KB
testcase_11 AC 674 ms
143,668 KB
testcase_12 AC 645 ms
143,096 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

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