結果
問題 | No.407 鴨等素数間隔列の数え上げ |
ユーザー | crazybbb3 |
提出日時 | 2016-11-27 16:33:00 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,290 bytes |
コンパイル時間 | 2,156 ms |
コンパイル使用メモリ | 77,360 KB |
実行使用メモリ | 58,580 KB |
最終ジャッジ日時 | 2024-11-27 12:13:05 |
合計ジャッジ時間 | 7,533 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 112 ms
58,204 KB |
testcase_01 | AC | 111 ms
58,428 KB |
testcase_02 | AC | 112 ms
58,204 KB |
testcase_03 | AC | 115 ms
58,452 KB |
testcase_04 | AC | 112 ms
58,500 KB |
testcase_05 | AC | 111 ms
58,444 KB |
testcase_06 | AC | 113 ms
58,216 KB |
testcase_07 | AC | 113 ms
58,396 KB |
testcase_08 | AC | 117 ms
58,400 KB |
testcase_09 | AC | 115 ms
58,320 KB |
testcase_10 | AC | 119 ms
58,480 KB |
testcase_11 | AC | 116 ms
58,392 KB |
testcase_12 | AC | 115 ms
58,580 KB |
testcase_13 | AC | 113 ms
58,204 KB |
testcase_14 | AC | 112 ms
58,444 KB |
testcase_15 | AC | 113 ms
58,380 KB |
testcase_16 | AC | 112 ms
58,240 KB |
testcase_17 | AC | 115 ms
58,420 KB |
testcase_18 | AC | 113 ms
58,424 KB |
testcase_19 | AC | 117 ms
58,320 KB |
testcase_20 | AC | 124 ms
58,444 KB |
testcase_21 | AC | 112 ms
58,244 KB |
testcase_22 | AC | 112 ms
58,448 KB |
testcase_23 | AC | 115 ms
58,356 KB |
testcase_24 | AC | 116 ms
58,448 KB |
testcase_25 | AC | 121 ms
58,320 KB |
testcase_26 | AC | 113 ms
58,412 KB |
testcase_27 | AC | 111 ms
58,448 KB |
testcase_28 | AC | 112 ms
58,496 KB |
testcase_29 | AC | 114 ms
58,448 KB |
testcase_30 | AC | 116 ms
58,188 KB |
testcase_31 | AC | 112 ms
58,400 KB |
testcase_32 | AC | 116 ms
58,460 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 122 ms
58,552 KB |
ソースコード
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(); } }