結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-06-13 16:52:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 523 bytes |
| コンパイル時間 | 552 ms |
| コンパイル使用メモリ | 76,624 KB |
| 実行使用メモリ | 7,620 KB |
| 最終ジャッジ日時 | 2024-07-06 19:45:29 |
| 合計ジャッジ時間 | 1,543 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long LL;
int main(){
int N;
double p;
cin >> N >> p;
vector<int> cnt(N+1);
for(int i = 2; i <= N; i++){
for(int j = i+i; j <= N; j+=i){
cnt[j]++;
}
}
double ans = 0.0;
for(int i = 2; i <= N; i++){
ans += pow(1.0 - p, cnt[i]);
}
cout << setprecision(13) << ans << endl;
return 0;
}
machy