結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
OUDON
|
| 提出日時 | 2015-10-06 16:28:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 964 bytes |
| コンパイル時間 | 1,666 ms |
| コンパイル使用メモリ | 158,436 KB |
| 実行使用メモリ | 7,808 KB |
| 最終ジャッジ日時 | 2024-07-20 01:45:00 |
| 合計ジャッジ時間 | 2,679 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
#define DEBUG(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define is_in(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
using namespace std;
typedef long long ll;
typedef vector<vector<int> > VVI;
const int INF = 1e9;
typedef pair<int, int> PII;
int d[1000001];
int main()
{
int N; cin >> N;
double P; cin >> P;
for (int i=2; i<=N; i++) {
for (int j=i*2; j<=N; j+=i) {
d[j]++;
}
}
double ans = 0;
for (int i=2; i<=N; i++) {
ans += pow(1-P, d[i]);
}
cout << fixed << setprecision(10);
cout << ans << endl;
}
OUDON