結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-04 04:12:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 1,000 ms
コード長 653 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 72,232 KB
実行使用メモリ 60,288 KB
最終ジャッジ日時 2023-08-22 06:43:24
合計ジャッジ時間 8,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,956 KB
testcase_01 AC 119 ms
55,808 KB
testcase_02 AC 120 ms
55,796 KB
testcase_03 AC 125 ms
56,160 KB
testcase_04 AC 120 ms
55,780 KB
testcase_05 AC 118 ms
55,612 KB
testcase_06 AC 124 ms
55,992 KB
testcase_07 AC 122 ms
55,900 KB
testcase_08 AC 118 ms
55,732 KB
testcase_09 AC 119 ms
55,816 KB
testcase_10 AC 118 ms
55,748 KB
testcase_11 AC 118 ms
55,876 KB
testcase_12 AC 120 ms
56,024 KB
testcase_13 AC 120 ms
55,776 KB
testcase_14 AC 122 ms
56,104 KB
testcase_15 AC 124 ms
55,936 KB
testcase_16 AC 119 ms
55,660 KB
testcase_17 AC 121 ms
55,600 KB
testcase_18 AC 122 ms
56,152 KB
testcase_19 AC 128 ms
56,204 KB
testcase_20 AC 134 ms
58,232 KB
testcase_21 AC 121 ms
55,420 KB
testcase_22 AC 124 ms
55,976 KB
testcase_23 AC 122 ms
56,164 KB
testcase_24 AC 119 ms
56,032 KB
testcase_25 AC 143 ms
57,944 KB
testcase_26 AC 117 ms
55,804 KB
testcase_27 AC 118 ms
55,732 KB
testcase_28 AC 118 ms
55,652 KB
testcase_29 AC 120 ms
55,904 KB
testcase_30 AC 122 ms
55,992 KB
testcase_31 AC 120 ms
55,724 KB
testcase_32 AC 132 ms
58,016 KB
testcase_33 AC 154 ms
57,548 KB
testcase_34 AC 159 ms
60,288 KB
testcase_35 AC 139 ms
58,048 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 L = sc.nextInt();
        int dlim = L/(N-1);
        boolean [] b = new boolean [dlim+1];
        long count=0L;
        if(dlim>=2){
            count+=L-2*(N-1)+1;
        }
        for(int i=3; i<=dlim; i+=2){
            if(b[i]==false){
                count+=L-i*(N-1)+1;
                int k=2;
                while(i*k<=dlim){
                    b[i*k]=true;
                    k++;
                }
            }
        }
        System.out.println(count);
    }
}
0