結果
| 問題 | No.144 エラトステネスのざる |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-04 16:05:29 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 441 bytes |
| 記録 | |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 91,916 KB |
| 実行使用メモリ | 8,044 KB |
| 最終ジャッジ日時 | 2026-03-20 06:25:31 |
| 合計ジャッジ時間 | 1,583 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}