結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー startcppstartcpp
提出日時 2016-08-05 22:46:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 120 ms / 1,000 ms
コード長 545 bytes
コンパイル時間 1,147 ms
コンパイル使用メモリ 51,520 KB
実行使用メモリ 13,136 KB
最終ジャッジ日時 2023-08-22 03:22:42
合計ジャッジ時間 3,253 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 9 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 107 ms
12,768 KB
testcase_06 AC 50 ms
9,456 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 29 ms
7,412 KB
testcase_21 AC 12 ms
4,620 KB
testcase_22 AC 10 ms
4,424 KB
testcase_23 AC 19 ms
5,204 KB
testcase_24 AC 29 ms
7,464 KB
testcase_25 AC 49 ms
9,488 KB
testcase_26 AC 49 ms
9,456 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 21 ms
7,428 KB
testcase_29 AC 48 ms
9,648 KB
testcase_30 AC 8 ms
4,380 KB
testcase_31 AC 39 ms
7,428 KB
testcase_32 AC 48 ms
9,716 KB
testcase_33 AC 112 ms
13,136 KB
testcase_34 AC 120 ms
13,124 KB
testcase_35 AC 98 ms
12,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define int long long
using namespace std;

int n, l;
bool isPrime[10000001];

signed main() {
	int i, j;
	
	cin >> n >> l;
	
	for (i = 2; i <= l; i++) {
		isPrime[i] = true;
	}
	for (i = 2; i <= l; i++) {
		if (isPrime[i]) {
			for (j = i * 2; j <= l; j += i) {
				isPrime[j] = false;
			}
		}
	}
	
	int ans = 0;
	for (i = 2; i <= l; i++) {
		if (!isPrime[i]) continue;
		
		int e = i * (n - 1);	//位置0を始点とした場合の終点e
		if (e > l) continue;
		
		ans += l - e + 1;
	}
	cout << ans << endl;
	return 0;
}
0