結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
36,960 KB
testcase_01 AC 50 ms
37,084 KB
testcase_02 AC 48 ms
36,960 KB
testcase_03 AC 74 ms
37,844 KB
testcase_04 AC 49 ms
36,704 KB
testcase_05 AC 49 ms
37,168 KB
testcase_06 AC 49 ms
37,164 KB
testcase_07 AC 48 ms
37,132 KB
testcase_08 AC 49 ms
37,000 KB
testcase_09 AC 48 ms
37,120 KB
testcase_10 AC 49 ms
37,028 KB
testcase_11 AC 49 ms
37,128 KB
testcase_12 AC 49 ms
37,072 KB
testcase_13 AC 48 ms
36,988 KB
testcase_14 AC 50 ms
37,228 KB
testcase_15 AC 50 ms
36,712 KB
testcase_16 AC 52 ms
37,048 KB
testcase_17 AC 49 ms
36,724 KB
testcase_18 AC 49 ms
37,188 KB
testcase_19 AC 124 ms
38,012 KB
testcase_20 AC 353 ms
37,636 KB
testcase_21 AC 54 ms
36,840 KB
testcase_22 AC 52 ms
37,164 KB
testcase_23 AC 50 ms
37,204 KB
testcase_24 AC 49 ms
37,048 KB
testcase_25 AC 658 ms
37,772 KB
testcase_26 AC 49 ms
36,988 KB
testcase_27 AC 49 ms
37,200 KB
testcase_28 AC 50 ms
36,952 KB
testcase_29 AC 49 ms
37,228 KB
testcase_30 AC 49 ms
37,120 KB
testcase_31 AC 50 ms
37,080 KB
testcase_32 AC 291 ms
37,692 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 579 ms
37,876 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;

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