結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー ikdikd
提出日時 2016-08-05 23:43:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 216 ms / 1,000 ms
コード長 699 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 59,052 KB
実行使用メモリ 81,596 KB
最終ジャッジ日時 2023-08-22 04:23:11
合計ジャッジ時間 3,443 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 13 ms
11,664 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 207 ms
79,244 KB
testcase_06 AC 87 ms
44,436 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 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,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 13 ms
11,652 KB
testcase_20 AC 40 ms
28,016 KB
testcase_21 AC 16 ms
15,764 KB
testcase_22 AC 13 ms
13,880 KB
testcase_23 AC 23 ms
19,808 KB
testcase_24 AC 38 ms
28,248 KB
testcase_25 AC 79 ms
44,436 KB
testcase_26 AC 80 ms
44,364 KB
testcase_27 AC 9 ms
9,548 KB
testcase_28 AC 26 ms
21,876 KB
testcase_29 AC 73 ms
42,584 KB
testcase_30 AC 11 ms
11,624 KB
testcase_31 AC 55 ms
36,180 KB
testcase_32 AC 79 ms
42,388 KB
testcase_33 AC 214 ms
81,548 KB
testcase_34 AC 216 ms
81,596 KB
testcase_35 AC 190 ms
75,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
long long arr[10000000];

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

int main(){

    long long N, L;
    cin>> N>> L;

    Eratosthenes(L);

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

    printf("%lld\n", ans);

    return 0;
}
0