結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー gu_21816943gu_21816943
提出日時 2017-06-27 01:08:26
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 815 bytes
コンパイル時間 1,906 ms
コンパイル使用メモリ 77,672 KB
実行使用メモリ 72,816 KB
最終ジャッジ日時 2024-04-15 02:01:57
合計ジャッジ時間 5,214 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
50,432 KB
testcase_01 AC 58 ms
50,144 KB
testcase_02 RE -
testcase_03 AC 64 ms
50,456 KB
testcase_04 AC 52 ms
50,296 KB
testcase_05 AC 52 ms
50,344 KB
testcase_06 AC 51 ms
50,236 KB
testcase_07 AC 51 ms
50,112 KB
testcase_08 AC 56 ms
50,108 KB
testcase_09 AC 51 ms
50,016 KB
testcase_10 AC 51 ms
50,256 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 51 ms
49,924 KB
testcase_14 AC 52 ms
50,284 KB
testcase_15 RE -
testcase_16 AC 52 ms
50,072 KB
testcase_17 AC 53 ms
50,148 KB
testcase_18 AC 52 ms
50,156 KB
testcase_19 AC 90 ms
53,572 KB
testcase_20 AC 104 ms
57,864 KB
testcase_21 AC 52 ms
50,260 KB
testcase_22 AC 52 ms
50,260 KB
testcase_23 AC 52 ms
50,296 KB
testcase_24 AC 52 ms
50,312 KB
testcase_25 AC 126 ms
62,560 KB
testcase_26 AC 52 ms
50,376 KB
testcase_27 RE -
testcase_28 AC 52 ms
50,300 KB
testcase_29 AC 52 ms
49,912 KB
testcase_30 AC 51 ms
49,900 KB
testcase_31 AC 53 ms
50,268 KB
testcase_32 AC 101 ms
55,860 KB
testcase_33 AC 171 ms
72,816 KB
testcase_34 AC 171 ms
72,812 KB
testcase_35 AC 121 ms
62,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		br.close();
		int num = Integer.parseInt(str[0]) - 1;
		int len = Integer.parseInt(str[1]);

		long count = 0;

		int n = len / num;

		int[] prime = new int[n];

		int i, j,primeNum;

		prime[0] = 0;
		for (i = 1; i < n; i++) {
			prime[i] = 1;
		}
		for (i = 1; i < n; i++) {
			if (prime[i] == 1) {
				primeNum = i + 1;

				for(j=i+primeNum;j<n;j+=primeNum){
					prime[j]=0;
				}
			}
		}

		for(i=1;i<n;i++){
			if(prime[i]==1){
				primeNum=i+1;
				count+=len-num*(i+1)+1;
			}
		}

		System.out.println(count);
	}
}
0