結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー naimonon77naimonon77
提出日時 2016-08-08 20:09:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 235 ms / 1,000 ms
コード長 1,132 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 164,960 KB
実行使用メモリ 46,472 KB
最終ジャッジ日時 2023-08-22 04:57:04
合計ジャッジ時間 10,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
46,348 KB
testcase_01 AC 165 ms
46,296 KB
testcase_02 AC 167 ms
46,420 KB
testcase_03 AC 149 ms
46,468 KB
testcase_04 AC 143 ms
46,420 KB
testcase_05 AC 146 ms
46,352 KB
testcase_06 AC 149 ms
46,360 KB
testcase_07 AC 234 ms
46,312 KB
testcase_08 AC 229 ms
46,352 KB
testcase_09 AC 231 ms
46,400 KB
testcase_10 AC 232 ms
46,412 KB
testcase_11 AC 231 ms
46,352 KB
testcase_12 AC 235 ms
46,360 KB
testcase_13 AC 235 ms
46,300 KB
testcase_14 AC 228 ms
46,348 KB
testcase_15 AC 190 ms
46,352 KB
testcase_16 AC 149 ms
46,312 KB
testcase_17 AC 166 ms
46,352 KB
testcase_18 AC 162 ms
46,360 KB
testcase_19 AC 147 ms
46,356 KB
testcase_20 AC 151 ms
46,352 KB
testcase_21 AC 155 ms
46,360 KB
testcase_22 AC 153 ms
46,412 KB
testcase_23 AC 150 ms
46,444 KB
testcase_24 AC 176 ms
46,324 KB
testcase_25 AC 148 ms
46,320 KB
testcase_26 AC 154 ms
46,472 KB
testcase_27 AC 143 ms
46,332 KB
testcase_28 AC 147 ms
46,352 KB
testcase_29 AC 144 ms
46,368 KB
testcase_30 AC 167 ms
46,352 KB
testcase_31 AC 160 ms
46,348 KB
testcase_32 AC 152 ms
46,324 KB
testcase_33 AC 149 ms
46,356 KB
testcase_34 AC 147 ms
46,308 KB
testcase_35 AC 151 ms
46,356 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;
	rep(i, L) {
		if (L - prime[i] * (N - 1) < 0) break;
		cnt += L - prime[i] * (N - 1) + 1;
	}
	cout << cnt << endl;
	return 0;
}
0