結果

問題 No.144 エラトステネスのざる
ユーザー nvt4snvt4s
提出日時 2019-05-26 18:43:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 168,908 KB
実行使用メモリ 8,096 KB
最終ジャッジ日時 2023-10-17 18:00:51
合計ジャッジ時間 5,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,060 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int divisor(ll n){
    int res = 0;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res++;
            if(i != n/i) res++;
        }
    }
    return res;
}



int main(void){
    int N;
    double p;
    cin >> N >> p;
    double ans = 0.0;
    for(int i = 2; i <= N; i++){
        int x = divisor(i);
        x -= 2;
        ans += pow((1.0-p), x);
    }
    cout << ans << endl;
}
0