結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-07 03:23:17
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 748 bytes
コンパイル時間 4,492 ms
コンパイル使用メモリ 72,092 KB
実行使用メモリ 74,980 KB
最終ジャッジ日時 2023-09-07 08:40:07
合計ジャッジ時間 8,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,836 KB
testcase_01 AC 123 ms
55,792 KB
testcase_02 RE -
testcase_03 AC 144 ms
55,804 KB
testcase_04 AC 124 ms
55,924 KB
testcase_05 AC 125 ms
56,052 KB
testcase_06 AC 124 ms
55,848 KB
testcase_07 AC 123 ms
55,916 KB
testcase_08 AC 123 ms
55,784 KB
testcase_09 AC 122 ms
55,720 KB
testcase_10 AC 123 ms
56,020 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 123 ms
55,776 KB
testcase_14 AC 129 ms
56,096 KB
testcase_15 RE -
testcase_16 AC 125 ms
55,780 KB
testcase_17 AC 127 ms
55,612 KB
testcase_18 AC 126 ms
55,720 KB
testcase_19 AC 152 ms
58,032 KB
testcase_20 AC 168 ms
60,412 KB
testcase_21 AC 125 ms
55,876 KB
testcase_22 AC 126 ms
56,056 KB
testcase_23 AC 126 ms
53,420 KB
testcase_24 AC 128 ms
55,644 KB
testcase_25 AC 179 ms
62,144 KB
testcase_26 AC 123 ms
55,776 KB
testcase_27 RE -
testcase_28 AC 125 ms
55,720 KB
testcase_29 AC 126 ms
56,128 KB
testcase_30 AC 127 ms
56,136 KB
testcase_31 AC 124 ms
55,848 KB
testcase_32 AC 160 ms
60,136 KB
testcase_33 AC 226 ms
74,980 KB
testcase_34 AC 224 ms
74,616 KB
testcase_35 AC 177 ms
62,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long l = sc.nextLong();
    int t = (int)l / (n - 1);
    ArrayList<Long> prime = new ArrayList<Long>();
    boolean[] is_prime = new boolean[t + 1];
    for(int i = 0; i <= t; i++) is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 2; i <= t; i++) {
      if(is_prime[i]) {
        prime.add((long)i);
        for(int j = 2 * i; j <= t; j += i) is_prime[j] = false;
      }
    }
    long ans = 0;
    for(int i = 0; i < prime.size(); i++) {
      long p = prime.get(i);
      ans += (l + 1 - p * (long)(n - 1));
    }
    System.out.println(ans);    
  }
}
0