結果

問題 No.144 エラトステネスのざる
ユーザー kazuma
提出日時 2018-09-27 08:55:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 412 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 194,788 KB
最終ジャッジ日時 2025-01-06 13:47:26
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main()
{
	cout << fixed << setprecision(10);
	int N;
	ld p;
	cin >> N >> p;
	vector<ld> dp(N + 1, 1.0);
	ld res = 0;
	for (int i = 2; i <= N; i++) {
		res += dp[i];
		for (int j = i * 2; j <= N; j += i) {
			dp[j] *= (1 - p);
		}
	}
	for (int i = 2; i <= N; i++) {
		cout << dp[i] << " \n"[i == N];
	}
	cout << res << endl;
	return 0;
}
0