結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー pekempeypekempey
提出日時 2016-08-05 22:31:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 523 bytes
コンパイル時間 1,436 ms
コンパイル使用メモリ 148,528 KB
実行使用メモリ 14,268 KB
最終ジャッジ日時 2023-08-22 02:26:35
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 9 ms
4,436 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 71 ms
14,032 KB
testcase_06 AC 37 ms
8,068 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 23 ms
5,480 KB
testcase_21 AC 10 ms
4,384 KB
testcase_22 AC 9 ms
4,384 KB
testcase_23 AC 15 ms
5,336 KB
testcase_24 AC 22 ms
5,496 KB
testcase_25 AC 36 ms
8,836 KB
testcase_26 AC 36 ms
9,588 KB
testcase_27 AC 7 ms
4,380 KB
testcase_28 AC 17 ms
5,332 KB
testcase_29 AC 35 ms
9,052 KB
testcase_30 AC 8 ms
4,380 KB
testcase_31 AC 30 ms
9,220 KB
testcase_32 AC 35 ms
9,084 KB
testcase_33 AC 75 ms
14,268 KB
testcase_34 AC 75 ms
14,064 KB
testcase_35 AC 67 ms
12,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<long long> primes;

void sieve(int n) {
	vector<bool> is_prime(n, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i < n; i++) {
		if (is_prime[i]) {
			primes.push_back(i);
			for (int j = i * 2; j < n; j += i) {
				is_prime[j] = false;
			}
		}
	}
}

int main() {
	long long n, L;
	cin >> n >> L;

	sieve(L + 1);

	long long ans = 0;
	for (long long p : primes) {
		long long last = (n - 1) * p;
		ans += max(0ll, L - last + 1);
	}
	cout << ans << endl;
}
0