結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー suppy193suppy193
提出日時 2017-01-31 15:47:27
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 26,528 KB
実行使用メモリ 6,104 KB
最終ジャッジ日時 2023-08-25 14:17:21
合計ジャッジ時間 6,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int isprime(long long int n)
{
	int i;
	if(n == 2){
		return 1;
	}
	if(n % 2 == 0){
		return 0;
	}
	for(i = 3;i <= sqrt(n);i += 2){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
	
}

int main(void) {
	long long int n, l;
	long long int d_max;
	long long int i, j;
	int flag;
	long long int count = 0;
	scanf("%lld%lld", &n, &l);
	d_max = l / (n - 1);

	if(d_max >= 2){
		count += l - 2 * (n - 1) + 1;
	}
	if(d_max >= 3){
		count += l - 3 * (n - 1) + 1;
	}
	for(i = 1;i <= d_max / 6;i++){
		if(isprime(6 * i - 1) == 1){
			count += l - (6 * i - 1) * (n - 1) + 1;
		}
		if(isprime(6 * i + 1) == 1){
			count += l - (6 * i + 1) * (n - 1) + 1;
		}
	}
	printf("%lld\n", count);
	
	return 0;
}
0