結果

問題 No.144 エラトステネスのざる
ユーザー junkaijunkai
提出日時 2020-11-25 23:45:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 550 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 168,188 KB
実行使用メモリ 10,652 KB
最終ジャッジ日時 2024-07-23 19:33:25
合計ジャッジ時間 19,679 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int n;
    double p;
    cin >> n >> p;
    double ans = 0;
    for(int i = 2; i <= n; i++)
    {
        int cnt = 0;
        for(int j = 2; j * j <= i; j++)
        {
            if(i % j == 0)
            {
                cnt++;
                if(i / j != j) cnt++;
            }
        }
        ans += pow((1-p), cnt);
    }
    cout << fixed << setprecision(10) << ans << endl;
}
0