結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー gu_21816943gu_21816943
提出日時 2017-06-27 00:57:50
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 755 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 74,972 KB
実行使用メモリ 51,908 KB
最終ジャッジ日時 2024-04-15 02:01:48
合計ジャッジ時間 9,647 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
50,224 KB
testcase_01 AC 53 ms
50,280 KB
testcase_02 AC 51 ms
50,136 KB
testcase_03 AC 77 ms
51,068 KB
testcase_04 AC 52 ms
50,024 KB
testcase_05 AC 54 ms
50,052 KB
testcase_06 AC 54 ms
49,904 KB
testcase_07 AC 55 ms
50,428 KB
testcase_08 AC 56 ms
50,280 KB
testcase_09 AC 53 ms
50,268 KB
testcase_10 AC 53 ms
50,188 KB
testcase_11 AC 52 ms
50,340 KB
testcase_12 AC 52 ms
50,240 KB
testcase_13 AC 53 ms
50,240 KB
testcase_14 AC 53 ms
50,320 KB
testcase_15 AC 54 ms
50,304 KB
testcase_16 AC 53 ms
50,280 KB
testcase_17 AC 52 ms
50,120 KB
testcase_18 AC 53 ms
50,260 KB
testcase_19 AC 132 ms
51,204 KB
testcase_20 AC 348 ms
51,192 KB
testcase_21 AC 53 ms
50,168 KB
testcase_22 AC 52 ms
50,000 KB
testcase_23 AC 54 ms
50,340 KB
testcase_24 AC 52 ms
50,276 KB
testcase_25 AC 633 ms
51,080 KB
testcase_26 AC 52 ms
50,340 KB
testcase_27 AC 54 ms
50,052 KB
testcase_28 AC 53 ms
50,276 KB
testcase_29 AC 53 ms
50,208 KB
testcase_30 AC 53 ms
50,244 KB
testcase_31 AC 53 ms
50,296 KB
testcase_32 AC 281 ms
51,072 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 566 ms
51,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		br.close();
		int num = Integer.parseInt(str[0]) - 1;
		int len = Integer.parseInt(str[1]);

		long count = 0;
		
		int n=len/num;
		
		int i,j;

		if (num * 2 <= len) {
			count += len - num * 2 + 1;
		}
		boolean flag = true;
		for (i = 3; i <= n; i += 2) {
			for (j = 3; j * j <= i; j += 2) {
				if (i % j == 0) {
					flag = false;
					break;
				}
			}
			if (flag) {
				count += len - num * i + 1;
			}
			flag = true;
		}
		System.out.println(count);
	}
}
0