結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー okayunonahaokayunonaha
提出日時 2016-08-06 01:19:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 94 ms / 1,000 ms
コード長 600 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 25,860 KB
実行使用メモリ 12,728 KB
最終ジャッジ日時 2023-08-22 04:49:15
合計ジャッジ時間 2,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 84 ms
12,216 KB
testcase_06 AC 38 ms
9,168 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 24 ms
7,048 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 7 ms
4,380 KB
testcase_23 AC 14 ms
4,784 KB
testcase_24 AC 21 ms
7,096 KB
testcase_25 AC 40 ms
9,164 KB
testcase_26 AC 36 ms
8,984 KB
testcase_27 AC 5 ms
4,380 KB
testcase_28 AC 15 ms
7,076 KB
testcase_29 AC 34 ms
9,092 KB
testcase_30 AC 6 ms
4,376 KB
testcase_31 AC 28 ms
6,988 KB
testcase_32 AC 36 ms
9,040 KB
testcase_33 AC 94 ms
12,664 KB
testcase_34 AC 94 ms
12,728 KB
testcase_35 AC 80 ms
11,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
using namespace std;

bool x[10000010];
void sosu(int n, int l) {
	for (int i = 2; i <= l; i++) {
		if(!x[i]){
		for (int j = 2; i*j <= l; j++) {
			x[i * j] = true;
		}
		}
	}
	/*for (int i = 2; i <= l; i++) {
	if(!x[i]) cout << i << " ";
	}
	cout << endl;
	*/
}
int main(void) {
	long long int tmp, N, L, d, round = 0, ans = 1;
	scanf("%Ld %Ld", &N, &L);
	sosu(N,L);

	for (int i = 2; ; i++) {
		if(!x[i]){ d = i;
		tmp = (i-1) * (N-1)+N;
		if(tmp > L+1) break;
		else tmp = L+1 - tmp + 1;
		round += tmp;
		}
	}

	printf("%Ld\n", round);
	//else cout << 0 << endl;

	return 0;
}
0