結果

問題 No.106 素数が嫌い!2
ユーザー holegumaholeguma
提出日時 2015-08-19 23:44:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 992 bytes
コンパイル時間 2,080 ms
コンパイル使用メモリ 72,140 KB
実行使用メモリ 58,716 KB
最終ジャッジ日時 2023-09-25 13:39:19
合計ジャッジ時間 4,059 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
56,784 KB
testcase_01 AC 48 ms
49,688 KB
testcase_02 AC 43 ms
49,360 KB
testcase_03 AC 43 ms
49,416 KB
testcase_04 AC 77 ms
56,624 KB
testcase_05 AC 92 ms
58,716 KB
testcase_06 AC 93 ms
57,944 KB
testcase_07 AC 93 ms
58,548 KB
testcase_08 AC 53 ms
50,324 KB
testcase_09 AC 53 ms
48,188 KB
testcase_10 AC 92 ms
58,664 KB
testcase_11 AC 75 ms
54,412 KB
testcase_12 AC 91 ms
58,564 KB
testcase_13 AC 44 ms
47,976 KB
testcase_14 AC 43 ms
49,440 KB
testcase_15 AC 44 ms
49,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
StringTokenizer st=new StringTokenizer(line);
int n=Integer.parseInt(st.nextToken());
int k=Integer.parseInt(st.nextToken());
//boolean[] p=sieveOfEratosthenes(n);
int[] a=new int[n+1];
for(int i=2;i<=n;i++){
if(a[i]==0) for(int j=i;j<=n;j+=i) a[j]++;
//if(p[i]) for(int j=i;j<=n;j+=i) a[j]++;
}
int ans=0;
for(int i=2;i<=n;i++) if(a[i]>=k) ans++;
out.println(ans);
}
out.flush();
}
/*
public static boolean[] sieveOfEratosthenes(int n){
boolean[] p=new boolean[n+1];
Arrays.fill(p,true);
p[0]=false;
p[1]=false;
for(int i=2;i<=Math.sqrt(n);i++){
if(p[i]) for(int j=i+i;j<=n;j+=i) p[j]=false;
}
return p;
}
*/
}
0