結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2023-02-07 12:47:16 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 418 bytes |
コンパイル時間 | 1,002 ms |
コンパイル使用メモリ | 62,040 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-07-05 09:51:31 |
合計ジャッジ時間 | 2,861 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <iomanip>using namespace std;long double rr[1000001];int main() {int n;long double k;cin>>n>>k;k=1.0-k;for(int i=2;i<=n;i++){rr[i]=1.0;}for(int i=2;i<=n/2+3;i++){long double k2=k;int p=i*2;while(p<=n){rr[p]=rr[p]*k2;p+=i;}}long double ans=0.0;for(int i=2;i<=n;i++){ans+=rr[i];}cout << fixed <<setprecision(8) << ans<<endl;return 0;}