結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 18:56:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 314 ms / 1,000 ms
コード長 841 bytes
コンパイル時間 3,354 ms
コンパイル使用メモリ 77,628 KB
実行使用メモリ 69,964 KB
最終ジャッジ日時 2024-05-09 12:10:50
合計ジャッジ時間 9,734 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,540 KB
testcase_01 AC 131 ms
41,660 KB
testcase_02 AC 134 ms
41,420 KB
testcase_03 AC 160 ms
47,044 KB
testcase_04 AC 133 ms
41,528 KB
testcase_05 AC 297 ms
68,968 KB
testcase_06 AC 212 ms
57,016 KB
testcase_07 AC 134 ms
41,560 KB
testcase_08 AC 135 ms
41,092 KB
testcase_09 AC 135 ms
41,348 KB
testcase_10 AC 134 ms
41,724 KB
testcase_11 AC 132 ms
41,656 KB
testcase_12 AC 140 ms
41,884 KB
testcase_13 AC 132 ms
41,352 KB
testcase_14 AC 153 ms
41,804 KB
testcase_15 AC 134 ms
41,648 KB
testcase_16 AC 136 ms
41,868 KB
testcase_17 AC 133 ms
41,744 KB
testcase_18 AC 139 ms
41,512 KB
testcase_19 AC 166 ms
47,244 KB
testcase_20 AC 198 ms
51,424 KB
testcase_21 AC 160 ms
48,056 KB
testcase_22 AC 157 ms
47,888 KB
testcase_23 AC 164 ms
47,556 KB
testcase_24 AC 181 ms
51,860 KB
testcase_25 AC 231 ms
55,220 KB
testcase_26 AC 214 ms
55,012 KB
testcase_27 AC 152 ms
43,668 KB
testcase_28 AC 168 ms
48,276 KB
testcase_29 AC 213 ms
55,056 KB
testcase_30 AC 158 ms
44,028 KB
testcase_31 AC 191 ms
54,420 KB
testcase_32 AC 224 ms
55,276 KB
testcase_33 AC 307 ms
69,564 KB
testcase_34 AC 308 ms
69,964 KB
testcase_35 AC 314 ms
67,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
		static int INF = 2 << 27;
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			long N = sc.nextInt();
			long L = sc.nextInt();
			
			List<Integer> l = makePrimeList(L);
			long sum = 0;
			for(int i = 0; i < l.size(); i++) {
				long len = (N-1) * (long)l.get(i);
				if(len > L) break;
				sum += L - len+1;
			}
			System.out.println(sum);
			
			
		}
		
		static List<Integer> makePrimeList(long max) {
			List<Integer> ret = new ArrayList<>();
			boolean[] isntPrime = new boolean[(int)max+1];
			ret.add(2);
			for(int i = 3; i <= max; i += 2) {
				if(!isntPrime[i]) {
					ret.add(i);
					for(int j = i + i ; j <= max; j += i) {
						isntPrime[j] = true;
					}
				}
			}
			return ret;
		}
		

}
0