結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー dnishdnish
提出日時 2017-07-10 22:15:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 1,000 ms
コード長 547 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 168,936 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 12:35:38
合計ジャッジ時間 3,417 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;

vector<bool> primes;
void make_primes(int n)
{
	primes.resize(n + 1, true);
	primes[0] = primes[1] = false;
	REP(i, 2, sqrt(n))
	{
		if (primes[i])
		{
			for (int j = 0; i * (j + 2) < n; j++)
				primes[i * (j + 2)] = false;
		}
	}
}

int main() {
	int N,L;
	cin>>N>>L;
	make_primes(L);
	ll ans=0;
	REP(i,0,L) if(primes[i]){
		int mx=i*(N-1);
		if(L<mx) break;
		ans+=L-mx+1;
	}
	p(ans);
	return 0;
}
0