結果
問題 | No.144 エラトステネスのざる |
ユーザー | get_tanni |
提出日時 | 2024-03-14 13:10:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 1,143 bytes |
コンパイル時間 | 12,851 ms |
コンパイル使用メモリ | 204,352 KB |
実行使用メモリ | 11,376 KB |
最終ジャッジ日時 | 2024-03-14 13:11:06 |
合計ジャッジ時間 | 6,013 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,676 KB |
testcase_01 | AC | 2 ms
6,676 KB |
testcase_02 | AC | 2 ms
6,676 KB |
testcase_03 | AC | 2 ms
6,676 KB |
testcase_04 | AC | 2 ms
6,676 KB |
testcase_05 | AC | 2 ms
6,676 KB |
testcase_06 | AC | 2 ms
6,676 KB |
testcase_07 | AC | 2 ms
6,676 KB |
testcase_08 | AC | 2 ms
6,676 KB |
testcase_09 | AC | 2 ms
6,676 KB |
testcase_10 | AC | 2 ms
6,676 KB |
testcase_11 | AC | 2 ms
6,676 KB |
testcase_12 | AC | 2 ms
6,676 KB |
testcase_13 | AC | 302 ms
11,376 KB |
testcase_14 | AC | 309 ms
11,376 KB |
testcase_15 | AC | 307 ms
11,376 KB |
testcase_16 | AC | 289 ms
11,376 KB |
testcase_17 | AC | 291 ms
11,376 KB |
testcase_18 | AC | 295 ms
11,376 KB |
testcase_19 | AC | 91 ms
11,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using ld=long double; using P=array<ll,2>; #define rep(i,n) for (ll i=0;i<(n);i++) #define rep2(i,a,b) for (ll i=(a);i<(b);i++) #define repd(i,a,b) for (ll i=(a);i>=(b);i--) #define popcount __builtin_popcountll #define cin(a) ll a; cin >> a; #define cin2(a,b) ll a,b; cin >> a >> b; #define cin3(a,b,c) ll a,b,c; cin >> a >> b >> c; #define cinvec(v) vector<ll> v(N); rep(i,N) cin >> v[i]; #define cinvec2(v,n) vector<ll> v(n); rep(i,n) cin >> v[i]; #define cins(s) string s; cin >> s; #define cinc(c) char c; cin >> c; vector<ll> dx = {0,-1,0,1},dy = {1,0,-1,0}, ddx = {0,-1,-1,-1,0,1,1,1}, ddy = {1,1,0,-1,-1,-1,0,1}; void yesno(bool b) {cout << (b?"Yes":"No") << endl;} template<class T> void sortunique(vector<T> &V) {sort(V.begin(), V.end()); V.erase(unique(V.begin(), V.end()), V.end());} int main() { cin(N); ld p; cin >> p; vector<ll> nokori(N+1, 0); for(ll i=2; i<=N; i++){ for(ll j=i; j<=N; j+=i) nokori[j]++; } ld ans = 0; rep2(i, 2, N+1){ ans += pow(1-p, nokori[i]-1); } cout << fixed << setprecision(10) << ans << endl; return 0; }