結果

問題 No.144 エラトステネスのざる
ユーザー yakkiyakki
提出日時 2019-12-05 02:56:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,275 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 92,172 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-08 22:42:27
合計ジャッジ時間 4,739 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

set<ll> divisor(ll n){
    set<ll> s;
    for(ll i = 1; i*i <= n; i++){
        if(n % i == 0){
            if(i != 1) s.insert(i);
            if(i != 1) s.insert(n/i);
        }
    }
    return s;
}

double Pow(double a, int n){
    if(n == 0) return 1;
    double half = Pow(a,n/2);
    double res = half * half;
    if(n & 1) res = res * a;
    return res;
}

int main(){
    cout << fixed << setprecision(7);
    int N; cin >> N;
    double p; cin >> p;
    double ans = 0;
    repr(i,2,N+1){
        set<ll> div = divisor(i);
        double now = 1.0;
        now *= Pow(1-p,(int)div.size());
        ans += now;
    }
    cout << ans << endl;

}
0