結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2019-05-26 18:55:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 875 bytes |
コンパイル時間 | 1,640 ms |
コンパイル使用メモリ | 169,300 KB |
実行使用メモリ | 7,648 KB |
最終ジャッジ日時 | 2024-09-17 15:20:21 |
合計ジャッジ時間 | 3,078 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<int,int> Pint;typedef pair<ll, ll> P;//typedef pair<int, pair<int, int>> P;//typedef tuple<int,int,int> T;ll INFL = 1000000000000000010;//10^18 = 2^60int INF = 2147483600;//10^9ll MOD = 1000000007;vector<int> dy = {0,0,1,-1};vector<int> dx = {1,-1,0,0};//約数の個数の列挙//nlognvector<int> num_divisors_list(int n){vector<int> num(n+1);for(int i = 1; i <= n; i++){for(int j = i; j <= n; j += i){num[j]++;}}return num;}int main(void){int N;double p;cin >> N >> p;double ans = 0.0;vector<int> num = num_divisors_list(1000010);for(int i = 2; i <= N; i++){int x = num[i];x -= 2;ans += pow((1.0-p), x);}cout << fixed << setprecision(10) << ans << endl;}