結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
Lepton_s
|
| 提出日時 | 2015-02-11 00:08:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 2,000 ms |
| コード長 | 380 bytes |
| コンパイル時間 | 411 ms |
| コンパイル使用メモリ | 55,584 KB |
| 実行使用メモリ | 15,508 KB |
| 最終ジャッジ日時 | 2024-06-23 18:26:02 |
| 合計ジャッジ時間 | 1,404 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <iostream>
using namespace std;
#define N 1000100
int p[N];
double r[N];
int main(){
int n;
double q;
cin>>n>>q;
for(int i = 2; i <= n/2; i++)
for(int j = i*2; j <= n; j+=i)
p[j]++;
r[0] = 1.0;
for(int i = 1; i <= n; i++) r[i] = r[i-1]*(1.0-q);
double res = 0;
for(int i = 2; i <= n; i++)
res += r[p[i]];
cout.precision(9);
cout<<res<<endl;
return 0;
}
Lepton_s