結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー togari_takamototogari_takamoto
提出日時 2016-08-05 22:40:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 94 ms / 1,000 ms
コード長 833 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 150,016 KB
実行使用メモリ 9,844 KB
最終ジャッジ日時 2023-08-22 03:06:22
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 87 ms
9,364 KB
testcase_06 AC 47 ms
6,948 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 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,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 11 ms
4,376 KB
testcase_20 AC 29 ms
5,272 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 18 ms
4,540 KB
testcase_24 AC 29 ms
5,292 KB
testcase_25 AC 46 ms
6,512 KB
testcase_26 AC 45 ms
6,524 KB
testcase_27 AC 8 ms
4,380 KB
testcase_28 AC 21 ms
4,740 KB
testcase_29 AC 45 ms
6,316 KB
testcase_30 AC 9 ms
4,376 KB
testcase_31 AC 36 ms
5,868 KB
testcase_32 AC 44 ms
6,536 KB
testcase_33 AC 94 ms
9,692 KB
testcase_34 AC 94 ms
9,844 KB
testcase_35 AC 84 ms
9,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)

vb eratosthenes(ll n) {
	vb t(n + 1, true); t[0] = t[1] = false;
	for (ll i = 2; i <= n; ++i) if (t[i]) {
		for (ll j = 2 * i; j <= n; j += i) t[j] = false;
	}
	return t;
}

vl compress(const vb & t) {
	vl v; v.reserve((ll)(1.2 * t.size() / log(t.size())));
	REP(i, t.size()) if (t[i]) v.push_back(i);
	return v;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, l; cin >> n >> l;
	auto ps = compress(eratosthenes(l));
	ll sum = 0;
	for (ll p : ps) {
		ll rest = l - p * (n - 1);
		if (rest < 0) break;
		sum += rest + 1;
	}
	cout << sum << endl;
	return 0;
}
0