結果

問題 No.144 エラトステネスのざる
ユーザー hiro71687khiro71687k
提出日時 2023-01-14 00:02:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 4,233 ms
コンパイル使用メモリ 261,052 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2023-08-26 05:20:43
合計ジャッジ時間 6,050 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 85 ms
18,796 KB
testcase_14 AC 89 ms
18,976 KB
testcase_15 AC 86 ms
18,920 KB
testcase_16 AC 92 ms
18,972 KB
testcase_17 AC 85 ms
18,848 KB
testcase_18 AC 89 ms
18,964 KB
testcase_19 AC 87 ms
18,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0