結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2021-03-16 14:26:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 396 bytes |
コンパイル時間 | 1,433 ms |
コンパイル使用メモリ | 167,948 KB |
実行使用メモリ | 7,680 KB |
最終ジャッジ日時 | 2024-11-08 00:08:36 |
合計ジャッジ時間 | 2,529 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; vector<int> num(N+1,0); int j; for(int i=2;i*2<=N;i++){ j=2; while(i*j<=N){ num[i*j]++; j++; } } double p; cin>>p; double ans=0; for(int i=2;i<=N;i++){ ans+=pow(1-p,num[i]); } cout<<fixed<<setprecision(6)<<ans<<endl; }