結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー HAHAHAHAHAHA
提出日時 2016-08-08 14:19:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 139 ms / 1,000 ms
コード長 1,111 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 76,456 KB
実行使用メモリ 13,084 KB
最終ジャッジ日時 2023-08-22 04:55:35
合計ジャッジ時間 3,050 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,388 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 9 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 118 ms
12,676 KB
testcase_06 AC 55 ms
9,492 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 31 ms
7,396 KB
testcase_21 AC 13 ms
4,588 KB
testcase_22 AC 10 ms
4,576 KB
testcase_23 AC 19 ms
5,204 KB
testcase_24 AC 30 ms
7,652 KB
testcase_25 AC 49 ms
9,456 KB
testcase_26 AC 53 ms
9,436 KB
testcase_27 AC 7 ms
4,384 KB
testcase_28 AC 22 ms
7,388 KB
testcase_29 AC 50 ms
9,444 KB
testcase_30 AC 8 ms
4,380 KB
testcase_31 AC 41 ms
7,516 KB
testcase_32 AC 50 ms
9,496 KB
testcase_33 AC 130 ms
13,064 KB
testcase_34 AC 139 ms
13,084 KB
testcase_35 AC 111 ms
12,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<utility>
#include <fstream>
#include<set>
#include<map>
#include<cctype>
#include<cmath>
#include<algorithm>
#include <numeric>
using namespace std;


#define RALL(x) (x).rbegin(),(x).rend()
#define ALL(x) (x).begin(),(x).end()
#define repp(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define clr(a) memset((a), 0 ,sizeof(a))
#define found(s,e) ((s).find(e)!=(s).end())

typedef pair<int,int> P;
typedef vector<pair<int,int> > pii;
typedef map<string,int> mdi;



// not..

bool isPrime[10000001];

int main() {
	long long i,j,n,a;

	
	cin >> n >> a;
	for(i=2;i<=a;i++){
		isPrime[i]=true;
	}
	for (i=2;i<=a;i++){
		if(isPrime[i]) {
			for(j=i*2;j<=a;j+=i){
				isPrime[j]=false;
			}
		}
	}
	
	long long ans=0;
	for(i=2;i<=a;i++){
		if(!isPrime[i]) continue;
		
		long long b=i*(n-1);
		if (b>a) continue;
		
		ans+=(a-b)+1;
	}
	cout << ans << endl;
	return 0;
}
0