結果
| 問題 |
No.144 エラトステネスのざる
|
| ユーザー |
batsumaru
|
| 提出日時 | 2019-09-04 20:19:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 2,000 ms |
| コード長 | 895 bytes |
| コンパイル時間 | 1,769 ms |
| コンパイル使用メモリ | 170,392 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-12-29 16:20:11 |
| 合計ジャッジ時間 | 3,142 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())
double bpow(double a , ll b){
if (b == 0) return 1;
double ret, t;
if (b%2 == 0){
t = bpow(a, b/2);
ret = t*t;
}else{
t = bpow(a, (b-1)/2);
ret = a*t*t;
}
return ret;
}
int main(){
ll n; cin >> n;
double p; cin >> p;
//d[i] = iの正の約数の個数
vector<ll> d(n+1,0);
FOR(i,1,n+1){
for(ll j=1; i*j<=n; j++){
d[i*j]++;
}
}
double ans = 0.0;
FOR(k,2,n+1){
ans += bpow(1-p,d[k]-2);
}
cout << fixed << setprecision(10) << ans << endl;
}
batsumaru