結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 18:56:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 314 ms / 1,000 ms
コード長 841 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 79,932 KB
実行使用メモリ 83,012 KB
最終ジャッジ日時 2023-08-22 06:16:39
合計ジャッジ時間 9,935 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,728 KB
testcase_01 AC 124 ms
55,580 KB
testcase_02 AC 125 ms
55,572 KB
testcase_03 AC 149 ms
58,300 KB
testcase_04 AC 126 ms
55,768 KB
testcase_05 AC 283 ms
80,064 KB
testcase_06 AC 204 ms
68,452 KB
testcase_07 AC 123 ms
55,628 KB
testcase_08 AC 126 ms
55,792 KB
testcase_09 AC 122 ms
55,828 KB
testcase_10 AC 123 ms
55,864 KB
testcase_11 AC 123 ms
55,836 KB
testcase_12 AC 134 ms
56,100 KB
testcase_13 AC 124 ms
55,780 KB
testcase_14 AC 139 ms
55,756 KB
testcase_15 AC 124 ms
55,568 KB
testcase_16 AC 127 ms
55,828 KB
testcase_17 AC 124 ms
55,840 KB
testcase_18 AC 125 ms
55,772 KB
testcase_19 AC 152 ms
60,236 KB
testcase_20 AC 180 ms
64,572 KB
testcase_21 AC 151 ms
60,084 KB
testcase_22 AC 151 ms
60,140 KB
testcase_23 AC 161 ms
60,272 KB
testcase_24 AC 174 ms
64,388 KB
testcase_25 AC 213 ms
67,004 KB
testcase_26 AC 206 ms
67,004 KB
testcase_27 AC 143 ms
59,976 KB
testcase_28 AC 158 ms
60,100 KB
testcase_29 AC 202 ms
67,248 KB
testcase_30 AC 144 ms
58,040 KB
testcase_31 AC 198 ms
66,016 KB
testcase_32 AC 214 ms
65,352 KB
testcase_33 AC 310 ms
81,116 KB
testcase_34 AC 314 ms
83,012 KB
testcase_35 AC 299 ms
79,252 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