結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
|
提出日時 | 2022-08-06 23:42:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 358 bytes |
コンパイル時間 | 603 ms |
コンパイル使用メモリ | 68,704 KB |
実行使用メモリ | 11,400 KB |
最終ジャッジ日時 | 2024-09-16 17:25:15 |
合計ジャッジ時間 | 1,824 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 3 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main(){ int n; double p; cin>>n>>p; vector<double> candidate(n+1,1.0); double ans=0; for(int i=2;i<=n;i++){ if (candidate[i]<0) continue; ans+=candidate[i]; int next_cur=i*2; while(next_cur<=n){ candidate[next_cur]*=(1-p); next_cur+=i; } } cout<<ans<<endl; return 0; }