結果

問題 No.144 エラトステネスのざる
ユーザー MayimgMayimg
提出日時 2019-01-29 01:57:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 522 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 164,664 KB
実行使用メモリ 7,816 KB
最終ジャッジ日時 2024-04-16 16:54:13
合計ジャッジ時間 20,537 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	double p;
	cin >> p;
	vector<int> a(n);
	for (int i = 2; i <= n; i++) {
		int x = i;
		int c = 0;
		for (int j = 1; j * j <= x; j++) {
			if (x % j == 0) {
				if (x / j == j) c++;
				else c += 2;
			}
		}
		a[i] = c;
	}
	double ans = 0;
	for (int i = 2; i <= n; i++) {
		ans += pow(1.0 - p, a[i] - 2);
	}
	cout << setprecision(20) << fixed << ans << '\n';
	return 0;
}
0