結果

問題 No.144 エラトステネスのざる
ユーザー OUDONOUDON
提出日時 2015-10-06 16:28:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 964 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 144,496 KB
実行使用メモリ 7,916 KB
最終ジャッジ日時 2023-09-27 07:36:35
合計ジャッジ時間 2,915 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 59 ms
7,780 KB
testcase_14 AC 73 ms
7,916 KB
testcase_15 AC 80 ms
7,704 KB
testcase_16 AC 77 ms
7,776 KB
testcase_17 AC 79 ms
7,916 KB
testcase_18 AC 80 ms
7,872 KB
testcase_19 AC 51 ms
7,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0