結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー crazybbb3crazybbb3
提出日時 2016-11-27 16:33:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,290 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 77,872 KB
実行使用メモリ 58,620 KB
最終ジャッジ日時 2024-05-05 14:15:34
合計ジャッジ時間 6,881 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
58,408 KB
testcase_01 AC 111 ms
58,508 KB
testcase_02 AC 107 ms
58,112 KB
testcase_03 AC 106 ms
58,292 KB
testcase_04 AC 103 ms
58,320 KB
testcase_05 AC 109 ms
58,444 KB
testcase_06 AC 106 ms
58,080 KB
testcase_07 AC 106 ms
58,352 KB
testcase_08 AC 105 ms
58,516 KB
testcase_09 AC 102 ms
58,476 KB
testcase_10 AC 104 ms
58,104 KB
testcase_11 AC 106 ms
58,496 KB
testcase_12 AC 105 ms
58,492 KB
testcase_13 AC 104 ms
58,132 KB
testcase_14 AC 108 ms
58,180 KB
testcase_15 AC 105 ms
58,140 KB
testcase_16 AC 106 ms
58,080 KB
testcase_17 AC 107 ms
58,448 KB
testcase_18 AC 107 ms
58,324 KB
testcase_19 AC 107 ms
58,128 KB
testcase_20 AC 118 ms
58,568 KB
testcase_21 AC 114 ms
58,108 KB
testcase_22 AC 108 ms
58,084 KB
testcase_23 AC 107 ms
58,620 KB
testcase_24 AC 108 ms
58,468 KB
testcase_25 AC 116 ms
58,620 KB
testcase_26 AC 104 ms
58,148 KB
testcase_27 AC 107 ms
58,300 KB
testcase_28 AC 106 ms
58,228 KB
testcase_29 AC 109 ms
58,228 KB
testcase_30 AC 106 ms
58,444 KB
testcase_31 AC 110 ms
58,232 KB
testcase_32 AC 112 ms
58,240 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 116 ms
58,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int l = ni();

        cprime();

        long ans = 0;

        for (int i = 0; i < 1000000; i++) {
            if (prime[i] * (n - 1) > l) {
                break;
            }

            ans += l - prime[i] * (n - 1) + 1;
        }

        out.println(ans);
    }

    int prime_max = 4000000;
    int pidx = 0;
    int[] prime = new int[1000000];
    int[] divp = new int[prime_max];

    void cprime() {
        for (long i = 2; i < prime_max; i++) {
            if (divp[(int)i] == 0) {
                prime[pidx++] = (int)i;
                for (long j = i * i; j < prime_max; j += i) {
                    divp[(int)j] = (int)i;
                }
            }
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0