結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー tentententen
提出日時 2020-09-11 18:42:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 2,597 ms
コンパイル使用メモリ 70,788 KB
実行使用メモリ 59,604 KB
最終ジャッジ日時 2023-08-27 03:15:16
合計ジャッジ時間 8,907 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,092 KB
testcase_01 AC 118 ms
56,280 KB
testcase_02 AC 121 ms
56,076 KB
testcase_03 AC 128 ms
56,400 KB
testcase_04 WA -
testcase_05 AC 118 ms
56,012 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 117 ms
55,692 KB
testcase_10 WA -
testcase_11 AC 118 ms
55,980 KB
testcase_12 AC 118 ms
55,516 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 119 ms
55,328 KB
testcase_16 AC 120 ms
55,672 KB
testcase_17 WA -
testcase_18 AC 119 ms
55,648 KB
testcase_19 AC 131 ms
56,320 KB
testcase_20 AC 139 ms
58,240 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 120 ms
55,644 KB
testcase_24 AC 120 ms
56,008 KB
testcase_25 AC 147 ms
58,464 KB
testcase_26 AC 120 ms
55,904 KB
testcase_27 AC 120 ms
55,832 KB
testcase_28 AC 120 ms
56,024 KB
testcase_29 AC 121 ms
55,728 KB
testcase_30 WA -
testcase_31 AC 120 ms
56,080 KB
testcase_32 AC 137 ms
57,836 KB
testcase_33 AC 168 ms
58,524 KB
testcase_34 AC 168 ms
59,604 KB
testcase_35 AC 150 ms
57,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int length = sc.nextInt();
    	boolean[] isNotPrime = new boolean[length / (n - 1) + 2];
    	long ans = 0;
    	for (int i = 2; i < isNotPrime.length; i++) {
    	    if (!isNotPrime[i]) {
    	        ans += length - i * (n - 1) + 1;
    	        for (int j = 2; j * i < isNotPrime.length; j++) {
    	            isNotPrime[i * j] = true;
    	        }
    	    }
    	}
        System.out.println(ans);
	}
}
0