結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー olpheolphe
提出日時 2016-11-15 00:41:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 545 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 62,456 KB
実行使用メモリ 14,336 KB
最終ジャッジ日時 2024-05-04 13:41:47
合計ジャッジ時間 3,589 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 1 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 1 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "list"
#include "math.h"
using namespace std;

int N, L;
list <int>P;
long long int ans;
bool flag;

int main() {
	cin >> N >> L;
	P.push_back(2);
	for (int i = 3; i <= L/(N-1); i+=2) {
		flag = true;
		for (auto j = P.begin()++; j != P.end()&&(*j)<sqrt(i); ++j) {
			if (i % (*j) == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			P.push_back(i);
		}
	}
	for (auto i = P.begin(); i != P.end(); ++i) {
		if (L - (N - 1)*(*i) < 0)break;
		ans += L - (N - 1)*(*i) + 1;
	}
	cout << ans << "\n";
	return 0;
}
0