結果
問題 | No.144 エラトステネスのざる |
ユーザー | nanophoto12 |
提出日時 | 2021-01-24 15:22:17 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 1,086 bytes |
コンパイル時間 | 1,864 ms |
コンパイル使用メモリ | 199,876 KB |
実行使用メモリ | 7,192 KB |
最終ジャッジ日時 | 2023-08-30 22:43:00 |
合計ジャッジ時間 | 3,085 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,384 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | AC | 45 ms
7,096 KB |
testcase_14 | AC | 44 ms
7,192 KB |
testcase_15 | AC | 43 ms
7,140 KB |
testcase_16 | AC | 43 ms
7,140 KB |
testcase_17 | AC | 43 ms
7,024 KB |
testcase_18 | AC | 49 ms
7,180 KB |
testcase_19 | AC | 46 ms
7,104 KB |
ソースコード
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,b,n) for(ll a = b;a < n;a++) #include <bits/stdc++.h> using namespace std; template<typename T> void chmax(T& reference, T value) { reference = max(reference, value); } template<typename T> void chmin(T& reference, T value) { reference = min(reference, value); } constexpr double mpow(double x, ll n) { double ans = 1; while (n != 0) { if (n & 1) ans = ans * x; x = x * x; n = n >> 1; } return ans; } int main() { ll n; double p; cin >> n >> p; vector<int> table(n + 1, 0); for (int i = 2; i <= n; i++) { for (int j = 1; i * j <= n; j++) { table[i * j]++; } } double ex = 0; for (int i = 2; i <= n; i++) { int c = table[i]; double q = mpow(1-p, c - 1); ex += q; } cout << setprecision(10) << fixed << ex << endl; return 0; }