結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2023-01-14 00:02:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 618 bytes |
コンパイル時間 | 3,563 ms |
コンパイル使用メモリ | 251,492 KB |
最終ジャッジ日時 | 2025-02-10 03:22:47 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using namespace std;using ll=long long;using ld=long double;ld pie=3.14159265359;ll mod=998244353;ll inf=99999999999999999;int main(){ll n;cin >> n;ld p;cin >> p;vector<ld>memo(n+1,1);for (ll i = 2; i <=n; i++){for (ll j = 2; j >=0; j++){if (i*j>n){break;}memo[i*j]*=(1.0-p);}}ld ans=0;for (ll i = 2; i <=n; i++){ans+=memo[i];}cout << setprecision(20) << ans << endl;}