結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-04 08:31:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,127 bytes |
| コンパイル時間 | 1,872 ms |
| コンパイル使用メモリ | 171,824 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-11-27 22:05:32 |
| 合計ジャッジ時間 | 23,329 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 7 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
vector<ll> divisor(ll n) {
vector<ll> res;
for (ll i = 1; i*i <= n; ++i) {
if (n%i != 0) continue;
res.emplace_back(i);
if (i*i != n) res.emplace_back(n/i);
}
return res;
}
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(15);
int n;
long double p, ans = 0.0;
cin >> n >> p;
for (int i = 2; i <= n; ++i) {
auto res = divisor(i);
debug(i, res.size());
ans += powl(1-p, res.size()-2);
}
cout << ans << endl;
return 0;
}