結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー femtofemto
提出日時 2016-08-05 22:40:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 8,748 KB
最終ジャッジ日時 2024-04-24 15:51:27
合計ジャッジ時間 2,400 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 9 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 28 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 46 ms
6,084 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 43 ms
6,068 KB
testcase_33 AC 95 ms
8,612 KB
testcase_34 AC 94 ms
8,748 KB
testcase_35 AC 84 ms
8,500 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<int> sieve(int n) {
	vector<int> ps;
	vector<bool> is_prime(n + 1, true);

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

	int N, L;
	cin >> N >> L;

	vector<int> ps = sieve(L);

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