結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
62,088 KB
testcase_01 AC 130 ms
62,172 KB
testcase_02 AC 125 ms
62,292 KB
testcase_03 AC 129 ms
62,256 KB
testcase_04 AC 124 ms
62,292 KB
testcase_05 AC 129 ms
62,116 KB
testcase_06 AC 130 ms
62,476 KB
testcase_07 AC 128 ms
62,212 KB
testcase_08 AC 130 ms
62,428 KB
testcase_09 AC 125 ms
62,492 KB
testcase_10 AC 128 ms
62,288 KB
testcase_11 AC 133 ms
62,080 KB
testcase_12 AC 127 ms
62,320 KB
testcase_13 AC 128 ms
62,040 KB
testcase_14 AC 125 ms
62,112 KB
testcase_15 AC 126 ms
62,280 KB
testcase_16 AC 122 ms
62,084 KB
testcase_17 AC 127 ms
62,088 KB
testcase_18 AC 127 ms
62,104 KB
testcase_19 AC 130 ms
62,096 KB
testcase_20 AC 131 ms
62,244 KB
testcase_21 AC 123 ms
62,040 KB
testcase_22 AC 131 ms
62,272 KB
testcase_23 AC 127 ms
62,172 KB
testcase_24 AC 127 ms
62,272 KB
testcase_25 AC 134 ms
62,244 KB
testcase_26 AC 126 ms
62,276 KB
testcase_27 AC 125 ms
62,372 KB
testcase_28 AC 128 ms
62,404 KB
testcase_29 AC 135 ms
62,116 KB
testcase_30 AC 128 ms
62,296 KB
testcase_31 AC 144 ms
62,040 KB
testcase_32 AC 134 ms
62,328 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 134 ms
62,532 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;
    long[] prime = new long[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