結果

問題 No.144 エラトステネスのざる
ユーザー bonntanname0316bonntanname0316
提出日時 2020-06-03 16:14:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 815 ms / 2,000 ms
コード長 1,221 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 167,868 KB
実行使用メモリ 11,888 KB
最終ジャッジ日時 2023-08-16 13:42:26
合計ジャッジ時間 8,208 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 788 ms
11,748 KB
testcase_14 AC 806 ms
11,720 KB
testcase_15 AC 815 ms
11,668 KB
testcase_16 AC 809 ms
11,668 KB
testcase_17 AC 811 ms
11,688 KB
testcase_18 AC 814 ms
11,888 KB
testcase_19 AC 783 ms
11,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

ll yaku[6000000];

ll YAKU(ll x){
    if(yaku[x]>0) return yaku[x];
    if(x==1) return 1;
    ll K=2;
    ll Count=0;
    ll a=x;
    while(true){
        if(a%K){
            if(Count) return yaku[x]=(1+Count)*YAKU(a);
            else {
                if(K*K>a) return yaku[x]=2;
                K++;
            }
        }
        else{
            a/=K;
            Count++;
        }
    }
}

int main(){
    ll N; cin>>N; double p; cin>>p;
    double ans=0;
    //REP(i,2,N+1) cout<<i<<':'<<YAKU(i)<<endl;
    REP(i,2,N+1) ans+=pow(1-p,YAKU(i)-2);
    cout<<setprecision(7)<<ans<<endl;
}
0