結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー snrnsidysnrnsidy
提出日時 2021-06-15 01:00:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 1,000 ms
コード長 634 bytes
コンパイル時間 2,015 ms
コンパイル使用メモリ 200,968 KB
実行使用メモリ 22,728 KB
最終ジャッジ日時 2023-08-26 15:29:13
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
21,592 KB
testcase_01 AC 96 ms
21,536 KB
testcase_02 AC 97 ms
21,580 KB
testcase_03 AC 98 ms
21,652 KB
testcase_04 AC 96 ms
21,500 KB
testcase_05 AC 98 ms
22,132 KB
testcase_06 AC 94 ms
22,728 KB
testcase_07 AC 94 ms
21,152 KB
testcase_08 AC 93 ms
21,496 KB
testcase_09 AC 93 ms
22,436 KB
testcase_10 AC 91 ms
21,384 KB
testcase_11 AC 98 ms
21,228 KB
testcase_12 AC 94 ms
21,908 KB
testcase_13 AC 94 ms
21,288 KB
testcase_14 AC 93 ms
21,196 KB
testcase_15 AC 95 ms
21,816 KB
testcase_16 AC 93 ms
22,524 KB
testcase_17 AC 94 ms
21,216 KB
testcase_18 AC 94 ms
21,576 KB
testcase_19 AC 94 ms
21,532 KB
testcase_20 AC 95 ms
22,328 KB
testcase_21 AC 93 ms
21,352 KB
testcase_22 AC 93 ms
21,908 KB
testcase_23 AC 95 ms
22,052 KB
testcase_24 AC 95 ms
21,396 KB
testcase_25 AC 94 ms
21,928 KB
testcase_26 AC 93 ms
21,304 KB
testcase_27 AC 93 ms
21,976 KB
testcase_28 AC 95 ms
22,220 KB
testcase_29 AC 96 ms
21,328 KB
testcase_30 AC 95 ms
21,136 KB
testcase_31 AC 96 ms
21,520 KB
testcase_32 AC 95 ms
22,052 KB
testcase_33 AC 95 ms
22,300 KB
testcase_34 AC 95 ms
20,952 KB
testcase_35 AC 95 ms
21,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector <long long int> prime;
bool isprime[10000005];

void eratos()
{
	memset(isprime, true, sizeof(isprime));
	for (int i = 2; i <= 10000000; i++)
	{
		if (isprime[i])
		{
			prime.push_back(i);
			for (int j = 2 * i; j <= 10000000; j += i)
			{
				isprime[j] = false;
			}
		}
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long int N, L;
	long long int res = 0;

	cin >> N >> L;

	eratos();

	for (int i = 0; i < prime.size(); i++)
	{
		long long int val = L - (N - 1) * prime[i];
		if (val >= 0) res += (val + 1);
	}

	cout << res << '\n';

	return 0;
}
0