結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー naimonon77naimonon77
提出日時 2016-08-08 20:14:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 185 ms / 1,000 ms
コード長 1,127 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 164,512 KB
実行使用メモリ 46,580 KB
最終ジャッジ日時 2023-08-22 04:58:36
合計ジャッジ時間 9,566 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
46,528 KB
testcase_01 AC 178 ms
46,404 KB
testcase_02 AC 173 ms
46,328 KB
testcase_03 AC 173 ms
46,472 KB
testcase_04 AC 172 ms
46,432 KB
testcase_05 AC 177 ms
46,340 KB
testcase_06 AC 178 ms
46,300 KB
testcase_07 AC 178 ms
46,292 KB
testcase_08 AC 174 ms
46,356 KB
testcase_09 AC 175 ms
46,296 KB
testcase_10 AC 173 ms
46,364 KB
testcase_11 AC 177 ms
46,364 KB
testcase_12 AC 171 ms
46,380 KB
testcase_13 AC 178 ms
46,312 KB
testcase_14 AC 173 ms
46,296 KB
testcase_15 AC 172 ms
46,580 KB
testcase_16 AC 178 ms
46,324 KB
testcase_17 AC 175 ms
46,336 KB
testcase_18 AC 179 ms
46,368 KB
testcase_19 AC 176 ms
46,304 KB
testcase_20 AC 175 ms
46,300 KB
testcase_21 AC 179 ms
46,556 KB
testcase_22 AC 176 ms
46,348 KB
testcase_23 AC 180 ms
46,316 KB
testcase_24 AC 176 ms
46,300 KB
testcase_25 AC 185 ms
46,356 KB
testcase_26 AC 183 ms
46,336 KB
testcase_27 AC 180 ms
46,300 KB
testcase_28 AC 176 ms
46,324 KB
testcase_29 AC 180 ms
46,332 KB
testcase_30 AC 179 ms
46,304 KB
testcase_31 AC 181 ms
46,312 KB
testcase_32 AC 179 ms
46,328 KB
testcase_33 AC 172 ms
46,380 KB
testcase_34 AC 171 ms
46,328 KB
testcase_35 AC 180 ms
46,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e7 + 5

static int prime[MAX + 5];
static int isprime[MAX + 5];
void Eratosthenes(int N) {
	for (int i = 0; i < N; i++) {
		isprime[i] = 1;
	}
	for (int i = 2; i < sqrt((double)N); i++) {
		if (isprime[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				isprime[i *(j + 2)] = 0;
			}
		}
	}
	int a = 0;
	for (int i = 2; i < N; i++) {
		if (isprime[i]) {
			prime[a++] = i;
		}
	}
}

signed main() {
	ll i, j, k, l;
	ll N,L;
	cin >> N >> L;
	Eratosthenes(MAX - 3);
	ll cnt = 0;
	for(auto &p:prime) {
		if (L - p * (N - 1) < 0) break;
		cnt += L - p * (N - 1) + 1;
	}
	cout << cnt << endl;
	return 0;
}
0