結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 👑 yumechiyumechi
提出日時 2016-08-26 01:24:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,288 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 83,904 KB
実行使用メモリ 8,496 KB
最終ジャッジ日時 2024-04-25 18:05:33
合計ジャッジ時間 2,233 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
6,944 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
6,944 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
6,944 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.precision(16);

	int n, l;
	cin >> n >> l;

	int nummax = l / (n - 1) + 1;
	if(nummax < 2) {
		cout << 0 << endl;
		return 0;
	}

	bool primes[nummax];
	primes[0] = false;
	primes[1] = false;
	FOR(i, 2, nummax) primes[i] = true;

	FOR(i, 2, nummax) {
		if(primes[i]) {
			for(int j = i * 2; j < nummax; j += i) {
				primes[j] = false;
			}
		}
	}

	long ans = 0;
	REP(i, nummax) {
		if(primes[i]) {
			int t = (l + 1) - (n - 1) + i;
			if(t <= 0) break;
			ans += t;
		}
	}

	cout << ans << endl;
	return 0;
}
0