結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 19:16:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 295 ms / 1,000 ms
コード長 829 bytes
コンパイル時間 2,242 ms
コンパイル使用メモリ 77,868 KB
実行使用メモリ 81,436 KB
最終ジャッジ日時 2024-05-09 12:12:50
合計ジャッジ時間 9,603 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
52,692 KB
testcase_01 AC 124 ms
54,036 KB
testcase_02 AC 130 ms
54,184 KB
testcase_03 AC 157 ms
58,912 KB
testcase_04 AC 113 ms
52,776 KB
testcase_05 AC 276 ms
78,292 KB
testcase_06 AC 206 ms
66,372 KB
testcase_07 AC 126 ms
53,964 KB
testcase_08 AC 129 ms
54,148 KB
testcase_09 AC 128 ms
54,000 KB
testcase_10 AC 114 ms
53,136 KB
testcase_11 AC 125 ms
53,816 KB
testcase_12 AC 136 ms
54,108 KB
testcase_13 AC 129 ms
53,964 KB
testcase_14 AC 138 ms
54,128 KB
testcase_15 AC 125 ms
54,300 KB
testcase_16 AC 117 ms
53,008 KB
testcase_17 AC 130 ms
54,260 KB
testcase_18 AC 114 ms
52,692 KB
testcase_19 AC 155 ms
58,892 KB
testcase_20 AC 183 ms
63,144 KB
testcase_21 AC 151 ms
58,780 KB
testcase_22 AC 136 ms
58,028 KB
testcase_23 AC 153 ms
58,808 KB
testcase_24 AC 171 ms
63,408 KB
testcase_25 AC 214 ms
64,996 KB
testcase_26 AC 208 ms
65,092 KB
testcase_27 AC 140 ms
56,264 KB
testcase_28 AC 159 ms
58,948 KB
testcase_29 AC 189 ms
64,224 KB
testcase_30 AC 147 ms
56,448 KB
testcase_31 AC 184 ms
63,816 KB
testcase_32 AC 213 ms
65,060 KB
testcase_33 AC 290 ms
81,236 KB
testcase_34 AC 295 ms
81,436 KB
testcase_35 AC 284 ms
77,368 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