結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー newlife171128
提出日時 2018-01-16 22:23:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 714 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 81,016 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 05:54:32
合計ジャッジ時間 3,178 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 25 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>

typedef long long ll;

using namespace std;

bool prime[1000001];

void sieve(int n){

	for(int i=0; i<=n; i++){
		prime[i] =true;
	}

	for(int i=2; i<=n; i++){
		for(int j=2*i; j<=n; j +=i){

			prime[j] = false;

		}
	}
}
int main() {

	int N=0,L=0;
	cin>>N>>L;

	sieve(L/(N-1));


	ll ans=0;
	for(int i=2; i<=L/(N-1); i++){
		if(prime[i]){

			if(L>=(i+(i*(N-2)))){
			ll p = L-(i+(i*(N-2)));
		/*	cout<<(i+(i*(N-2)))<<endl;*/
			ans += p+1;
			}


		}
	}

	cout<<ans<<endl;

	return 0;
}
0