結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
|
提出日時 | 2020-06-04 08:37:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 304 ms / 2,000 ms |
コード長 | 1,155 bytes |
コンパイル時間 | 1,825 ms |
コンパイル使用メモリ | 172,796 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-11-27 22:16:07 |
合計ジャッジ時間 | 4,444 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#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; vector<int> div(n+1,0); for (int i = 2; i <= n; ++i) { for (int k = 0; k <= n; k+=i) { div[k]++; } ans += powl(1-p, div[i]-1); } cout << ans << endl; return 0; }