結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2019-05-26 18:43:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 754 bytes |
コンパイル時間 | 1,394 ms |
コンパイル使用メモリ | 169,496 KB |
実行使用メモリ | 10,528 KB |
最終ジャッジ日時 | 2024-09-17 15:19:50 |
合計ジャッジ時間 | 4,976 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 2 TLE * 1 -- * 6 |
ソースコード
#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^60 int INF = 2147483600;//10^9 ll MOD = 1000000007; vector<int> dy = {0,0,1,-1}; vector<int> dx = {1,-1,0,0}; int divisor(ll n){ int res = 0; for(ll i = 1; i * i <= n; i++){ if(n % i == 0){ res++; if(i != n/i) res++; } } return res; } int main(void){ int N; double p; cin >> N >> p; double ans = 0.0; for(int i = 2; i <= N; i++){ int x = divisor(i); x -= 2; ans += pow((1.0-p), x); } cout << ans << endl; }