結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2018-04-12 17:07:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 298 bytes |
コンパイル時間 | 628 ms |
コンパイル使用メモリ | 74,500 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2024-06-26 21:26:59 |
合計ジャッジ時間 | 1,645 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream>#include<cmath>#include<iomanip>using namespace std;int n;double p,ans;int a[1<<20];main(){cin>>n>>p;for(int i=2;i<=n;i++){for(int j=i*2;j<=n;j+=i){a[j]++;}}for(int i=2;i<=n;i++){ans+=pow(1-p,a[i]);}cout<<fixed<<setprecision(9)<<ans<<endl;}