結果

問題 No.144 エラトステネスのざる
ユーザー kotatsugame
提出日時 2018-04-12 17:02:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 217 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 63,344 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-26 21:26:50
合計ジャッジ時間 4,182 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 2 TLE * 1 -- * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int n;double p,ans;
main()
{
	cin>>n>>p;
	p=1-p;
	for(int i=2;i<=n;i++)
	{
		double now=1;
		for(int j=2;j<i;j++)
		{
			if(i%j==0)now*=p;
		}
		ans+=now;
	}
	cout<<ans<<endl;
}
0