結果

問題 No.144 エラトステネスのざる
ユーザー tabataba
提出日時 2017-05-20 08:49:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 137,248 KB
実行使用メモリ 11,160 KB
最終ジャッジ日時 2023-10-19 03:59:48
合計ジャッジ時間 2,635 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <random>
#include <vector>
#include <algorithm>
#include <array>
#include <functional>
#include <utility>
#include <regex>
#include <tuple>
#include <map>
#include <set>
#include <iostream>

using namespace std;

int main(){
	int n;
	double p,s=0;
	-scanf("%d%lf",&n,&p);
	p=1-p;
	vector<double> t(n+1,1.0);
	for(int i=2;i<=n;i++){
		for(int j=i*2;j<=n;j+=i){
			t[j]*=p;
		}
		s+=t[i];
	}
	cout<<s<<endl;
	return 0;
}
0