結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2015-09-22 01:04:28 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 608 bytes |
コンパイル時間 | 447 ms |
コンパイル使用メモリ | 58,744 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-07-19 08:33:51 |
合計ジャッジ時間 | 1,479 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>using namespace std;#include <cstdio>#include <string.h>#include <stdlib.h>#include <math.h>#define FOR(i,a,b) for((i)=(a);i<(b);i++)typedef long long ll;typedef unsigned long long ull;typedef long double lb;/* ここからが本編 */int main(void){int i,j,k;int n;double p;double e[1000000];double sum = 0;/* 100193は素数 */cin >> n >> p;FOR(i,2,n+1) e[i] = 1.0;for(i=2; i <= n/2+1; i++) {for(j=2; i*j <= n; j++) {e[i*j] *= (1 - p);}}FOR(i,2,n+1) sum += e[i];printf("%.14g\n",sum);return 0;}