結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-05 23:42:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 601 bytes |
| コンパイル時間 | 536 ms |
| コンパイル使用メモリ | 54,816 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 08:42:56 |
| 合計ジャッジ時間 | 18,737 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 7 |
ソースコード
#include<iostream>
#include<cstdio>
using namespace std;
const int BUF = 1000005;
int N;
double p;
void read() {
cin >> N >> p;
}
void work() {
double sum = 0;
for (int i = 2; i <= N; ++i) {
double toAdd = 1;
for (int j = 2; j * j <= i; ++j) {
if (j * j == i) {
toAdd *= (1 - p);
}
else if (i % j == 0) {
toAdd *= (1 - p);
toAdd *= (1 - p);
}
}
sum += toAdd;
}
printf("%.10lf\n", sum);
}
int main() {
read();
work();
return 0;
}