結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー aaaaaaaaaa
提出日時 2017-11-13 01:31:57
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 952 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 71,492 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-16 11:07:40
合計ジャッジ時間 3,950 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;

int main(){
	
	int n,l;
	cin>>n>>l;
	int x=l/(n-1);
	vector<int> d(x+1);
	rep(i,x+1){
		d[i]=1;
	}/*
	for(int i=2;i*i<=x;i++){
		if(d[i]==1){
			FOR(j,i+1,x+1){
				if(j%i==0)d[j]=0;
			}
		}
	}*/
	for(int i=2;i*i<=x;i++){
		if(d[i]==1){
			for(int j=2;j*d[i]<=x;j++){
				d[j*d[i]]=0;
			}
		}
	}


	/*FOR(i,2,x+1){
		if(d[i]==1){
			printf("%d\n",i);
		}
	}*/

	ll ans=0;
	FOR(i,2,x+1){
		ans+=(l-(n-1)*i+1)*d[i];
	}
	cout<<ans<<endl;

	return 0;
}
0