結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2020-07-15 14:58:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 305 ms / 2,000 ms |
コード長 | 750 bytes |
コンパイル時間 | 1,954 ms |
コンパイル使用メモリ | 167,824 KB |
実行使用メモリ | 7,804 KB |
最終ジャッジ日時 | 2024-11-21 21:40:03 |
合計ジャッジ時間 | 4,386 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using P = pair<ll, ll>; const long double PI = acos(-1.0L); ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; } ll LCM(ll a, ll b) { return a/GCD(a, b)*b; } int n; int d[1000100]; int main() { cin >> n; long double p; cin >> p; long double ans = 0.0; memset(d, 0, sizeof(d)); for(int i = 2; i <= n; ++i) { for(int m = i; m <= n; m+=i) { d[m]++; } ans += powl((1LL-p), d[i]-1); } cout << setprecision(14) << ans << endl; }