結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2016-09-12 14:00:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 141 ms / 2,000 ms |
コード長 | 596 bytes |
コンパイル時間 | 2,954 ms |
コンパイル使用メモリ | 164,044 KB |
実行使用メモリ | 22,016 KB |
最終ジャッジ日時 | 2024-06-12 04:18:29 |
合計ジャッジ時間 | 4,665 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
import std.algorithm, std.array, std.container, std.range, std.bitmanip;import std.numeric, std.math, std.bigint, std.random, core.bitop;import std.string, std.regex, std.conv, std.stdio, std.typecons;void main(){auto rd = readln.split;auto n = rd[0].to!int, p = rd[1].to!real;auto memo = new int[](n + 1);foreach (i; 2..n + 1)foreach (j; iota(i * 2, n + 1, i))memo[j] += 1;auto ri = new real[](n + 1);foreach (i; 2..n + 1) {auto d = memo[i];if (d == 0)ri[i] = 1;elseri[i] = (1 - p) ^^ d;}writefln("%.7f", ri[2..$].sum);}