結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー olpheolphe
提出日時 2016-11-15 00:45:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 455 ms / 1,000 ms
コード長 546 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 63,380 KB
実行使用メモリ 14,260 KB
最終ジャッジ日時 2023-08-22 06:41:43
合計ジャッジ時間 3,418 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 28 ms
4,660 KB
testcase_20 AC 103 ms
6,924 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 191 ms
9,084 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 80 ms
6,416 KB
testcase_33 AC 455 ms
14,216 KB
testcase_34 AC 454 ms
14,260 KB
testcase_35 AC 169 ms
8,544 KB
権限があれば一括ダウンロードができます

ソースコード

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