結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー ikdikd
提出日時 2016-08-05 23:14:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 59,356 KB
実行使用メモリ 42,496 KB
最終ジャッジ日時 2024-04-24 16:58:31
合計ジャッジ時間 2,616 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 9 ms
7,296 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 10 ms
7,424 KB
testcase_20 AC 33 ms
15,232 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 58 ms
23,040 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 57 ms
22,528 KB
testcase_33 AC 188 ms
42,496 KB
testcase_34 AC 169 ms
42,368 KB
testcase_35 AC 140 ms
38,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<math.h>

using namespace std;
int arr[10000000];

void Eratosthenes(int N){
	for(int i=0; i<N; i++){
		arr[i]=1;
	}
	for(int i=2; i<sqrt(N); i++){
		if(arr[i]){
			for(int j=0; i*(j + 2)<N; j++){
				arr[i*(j+2)]=0;
			}
		}
	}
/*
	for(int i = 2; i < N; i++){
		if(arr[i]){
			//cout << i << endl;
		}
	}
*/
    arr[1]=0;
    arr[0]=-1;
}

int main(){

    int N, L;
    cin>> N>> L;

    Eratosthenes(L);

    long long ans=0;
    for(int i=2; i<=L; i++){
        if(arr[i]==0) continue;
        int mi=(N-1)*i;
        if(mi>L) continue;
        ans=ans+(L-mi+1);
    }

    cout<< ans<< endl;

    return 0;
}
0