結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 19:00:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 438 ms / 1,000 ms
コード長 841 bytes
コンパイル時間 3,530 ms
コンパイル使用メモリ 77,592 KB
実行使用メモリ 69,684 KB
最終ジャッジ日時 2024-05-09 12:11:57
合計ジャッジ時間 11,659 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
41,264 KB
testcase_01 AC 162 ms
41,292 KB
testcase_02 AC 157 ms
41,372 KB
testcase_03 AC 185 ms
47,532 KB
testcase_04 AC 153 ms
41,348 KB
testcase_05 AC 433 ms
68,688 KB
testcase_06 AC 263 ms
56,988 KB
testcase_07 AC 154 ms
41,608 KB
testcase_08 AC 155 ms
41,368 KB
testcase_09 AC 156 ms
41,236 KB
testcase_10 AC 155 ms
41,280 KB
testcase_11 AC 154 ms
41,316 KB
testcase_12 AC 166 ms
41,992 KB
testcase_13 AC 159 ms
41,232 KB
testcase_14 AC 169 ms
41,664 KB
testcase_15 AC 151 ms
41,608 KB
testcase_16 AC 153 ms
41,600 KB
testcase_17 AC 154 ms
41,420 KB
testcase_18 AC 153 ms
41,432 KB
testcase_19 AC 192 ms
47,256 KB
testcase_20 AC 227 ms
51,532 KB
testcase_21 AC 187 ms
47,836 KB
testcase_22 AC 182 ms
47,412 KB
testcase_23 AC 189 ms
47,464 KB
testcase_24 AC 216 ms
51,752 KB
testcase_25 AC 267 ms
55,612 KB
testcase_26 AC 252 ms
55,276 KB
testcase_27 AC 169 ms
43,912 KB
testcase_28 AC 189 ms
48,096 KB
testcase_29 AC 245 ms
55,500 KB
testcase_30 AC 174 ms
44,252 KB
testcase_31 AC 224 ms
54,176 KB
testcase_32 AC 264 ms
55,472 KB
testcase_33 AC 438 ms
69,684 KB
testcase_34 AC 421 ms
69,292 KB
testcase_35 AC 413 ms
67,760 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