結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2016-10-22 13:03:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 446 bytes |
コンパイル時間 | 546 ms |
コンパイル使用メモリ | 53,376 KB |
実行使用メモリ | 7,040 KB |
最終ジャッジ日時 | 2024-11-23 17:05:48 |
合計ジャッジ時間 | 1,820 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <cstdio>#include <vector>#include <cmath>#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))using namespace std;int main() {int n; double p; scanf("%d%lf", &n, &p);double ans = 0;vector<int> factor(n+1, 0);repeat_from (i,2,n+1) {ans += pow(1 - p, factor[i]);for (int j = 2*i; j < n+1; j += i) {factor[j] += 1;}}printf("%.8lf\n", ans);return 0;}