結果
問題 | No.144 エラトステネスのざる |
ユーザー | troro_kelp |
提出日時 | 2018-10-08 11:27:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 1,487 bytes |
コンパイル時間 | 972 ms |
コンパイル使用メモリ | 95,332 KB |
実行使用メモリ | 11,484 KB |
最終ジャッジ日時 | 2023-08-02 18:20:30 |
合計ジャッジ時間 | 2,674 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
11,480 KB |
testcase_01 | AC | 8 ms
11,452 KB |
testcase_02 | AC | 9 ms
11,484 KB |
testcase_03 | AC | 6 ms
11,456 KB |
testcase_04 | AC | 6 ms
11,304 KB |
testcase_05 | AC | 6 ms
11,440 KB |
testcase_06 | AC | 31 ms
11,360 KB |
testcase_07 | AC | 31 ms
11,320 KB |
testcase_08 | AC | 31 ms
11,476 KB |
testcase_09 | AC | 31 ms
11,448 KB |
testcase_10 | AC | 31 ms
11,304 KB |
testcase_11 | AC | 31 ms
11,364 KB |
testcase_12 | AC | 31 ms
11,480 KB |
testcase_13 | AC | 48 ms
11,440 KB |
testcase_14 | AC | 48 ms
11,452 KB |
testcase_15 | AC | 48 ms
11,476 KB |
testcase_16 | AC | 48 ms
11,316 KB |
testcase_17 | AC | 48 ms
11,440 KB |
testcase_18 | AC | 50 ms
11,320 KB |
testcase_19 | AC | 48 ms
11,320 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <cmath> #include <queue> #include <numeric> #include <climits> #include <iterator> #include <iomanip> #include <stack> #include <set> #include <cstdio> #include <bitset> #include <functional> #include <tuple> #include <list> #include <deque> #include <sstream> using namespace std; const constexpr int INF = 1e9; #define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i) #define REP(i, n) FOR(i, 0, n) typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> P; struct Less{ bool operator()(const pair<string, int>&a, const pair<string, int>&b){ if(a.first==b.first){ return a.second < b.second; } return a.first < b.first; } }; const constexpr ll MOD = 1e9; ll extGCD(ll a, ll b, ll& x, ll& y){ if(b==0){ x=1; y=0; return a; } ll d = extGCD(b, a%b, y, x); y -= a/b*x; return d; } ll GCD(ll a, ll b){ if(a<b) swap(a, b); if(b==0) return a; return GCD(b, a%b); } double zaru[1000010]; int main() { for(int i=2; i<1000010; ++i) zaru[i]=1.0; int N; cin >> N; double p; cin >> p; p = 1.0-p; for(int i=2; i<=N; ++i){ for(int j=2; j*i<1000010; ++j){ zaru[i*j]*=p; } } double ans=0.0; for(int i=2; i<=N; ++i){ ans += zaru[i]; } cout << fixed << setprecision(15)<< ans << endl; return 0; }