結果
| 問題 | No.144 エラトステネスのざる |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-12 17:06:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 256 bytes |
| 記録 | |
| コンパイル時間 | 544 ms |
| コンパイル使用メモリ | 67,712 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-06-26 21:26:57 |
| 合計ジャッジ時間 | 1,577 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 3 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#include<iostream>
#include<cmath>
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<<ans<<endl;
}