結果
| 問題 |
No.144 エラトステネスのざる
|
| ユーザー |
|
| 提出日時 | 2018-06-04 16:05:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 441 bytes |
| コンパイル時間 | 653 ms |
| コンパイル使用メモリ | 74,080 KB |
| 実行使用メモリ | 7,888 KB |
| 最終ジャッジ日時 | 2024-06-30 09:41:15 |
| 合計ジャッジ時間 | 1,760 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int factor[1000001] = {};
int main(){
int n;
double p;
cin >> n >> p;
for(int i = 2; i <= n; i++){
for(int j = i+i; j <= n; j += i){
factor[j]++;
}
}
double ans = 0;
for(int i = 2; i <= n; i++){
ans += pow(1-p, factor[i]);
}
cout << fixed << setprecision(7) << ans << endl;
return 0;
}