結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-03 16:14:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 752 ms / 2,000 ms |
| コード長 | 1,221 bytes |
| コンパイル時間 | 1,309 ms |
| コンパイル使用メモリ | 168,952 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-11-25 02:53:05 |
| 合計ジャッジ時間 | 6,916 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#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;
}