結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー femtofemto
提出日時 2016-08-05 22:41:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 1,000 ms
コード長 836 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 81,488 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2023-08-22 03:11:03
合計ジャッジ時間 3,210 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 113 ms
13,740 KB
testcase_06 AC 60 ms
8,140 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 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 3 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 13 ms
4,448 KB
testcase_20 AC 35 ms
5,408 KB
testcase_21 AC 16 ms
4,376 KB
testcase_22 AC 14 ms
4,376 KB
testcase_23 AC 24 ms
5,600 KB
testcase_24 AC 35 ms
5,688 KB
testcase_25 AC 59 ms
9,140 KB
testcase_26 AC 59 ms
9,328 KB
testcase_27 AC 10 ms
4,376 KB
testcase_28 AC 26 ms
5,396 KB
testcase_29 AC 56 ms
8,288 KB
testcase_30 AC 12 ms
4,376 KB
testcase_31 AC 47 ms
9,040 KB
testcase_32 AC 57 ms
8,780 KB
testcase_33 AC 117 ms
13,824 KB
testcase_34 AC 118 ms
12,800 KB
testcase_35 AC 105 ms
12,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
template<typename T> void setmin(T& a, T& b) { a = min(a, b); }
template<typename T> void setmax(T& a, T& b) { a = max(a, b); }

typedef long long ll;

vector<ll> sieve(ll n) {
	vector<ll> ps;
	vector<bool> is_prime(n + 1, true);

	is_prime[0] = is_prime[1] = false;
	for(ll i = 2; i <= n; i++) {
		if(is_prime[i]) {
			ps.push_back(i);
			for(ll j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return ps;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N, L;
	cin >> N >> L;

	vector<ll> ps = sieve(L);

	ll ans = 0;
	for(int p : ps) {
		ll rem = L - (N + (N - 1) * (p - 1) - 1);
		if(rem >= 0) {
			ans += rem + 1;
		}
	}
	cout << ans << endl;
}
0