結果

問題 No.36 素数が嫌い!
ユーザー holegumaholeguma
提出日時 2015-08-05 20:44:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 172 ms / 5,000 ms
コード長 641 bytes
コンパイル時間 2,326 ms
コンパイル使用メモリ 74,316 KB
実行使用メモリ 63,240 KB
最終ジャッジ日時 2023-09-09 07:14:48
合計ジャッジ時間 6,068 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
55,824 KB
testcase_01 AC 123 ms
57,660 KB
testcase_02 AC 43 ms
49,492 KB
testcase_03 AC 43 ms
49,228 KB
testcase_04 AC 45 ms
49,032 KB
testcase_05 AC 48 ms
50,148 KB
testcase_06 AC 47 ms
49,744 KB
testcase_07 AC 49 ms
50,044 KB
testcase_08 AC 44 ms
49,152 KB
testcase_09 AC 46 ms
49,152 KB
testcase_10 AC 45 ms
49,292 KB
testcase_11 AC 112 ms
54,124 KB
testcase_12 AC 172 ms
63,240 KB
testcase_13 AC 171 ms
63,140 KB
testcase_14 AC 111 ms
55,588 KB
testcase_15 AC 43 ms
49,088 KB
testcase_16 AC 43 ms
49,716 KB
testcase_17 AC 43 ms
49,164 KB
testcase_18 AC 43 ms
47,236 KB
testcase_19 AC 102 ms
53,584 KB
testcase_20 AC 139 ms
62,988 KB
testcase_21 AC 122 ms
57,848 KB
testcase_22 AC 123 ms
57,764 KB
testcase_23 AC 106 ms
55,884 KB
testcase_24 AC 114 ms
55,840 KB
testcase_25 AC 110 ms
55,912 KB
testcase_26 AC 134 ms
54,160 KB
testcase_27 AC 157 ms
57,788 KB
testcase_28 AC 131 ms
55,756 KB
testcase_29 AC 167 ms
63,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
boolean[] p;
while((line=br.readLine())!=null){
long n=Long.parseLong(line);
p=new boolean[(int)Math.sqrt(n)+1];
Arrays.fill(p,true);
p[0]=false;
p[1]=false;
for(int i=2;i<=Math.sqrt(Math.sqrt(n));i++){
if(p[i]){
for(int j=i+i;j<=Math.sqrt(n);j+=i){
p[j]=false;
}
}
}
String ans="NO";
int cnt=0;
for(int i=2;i<Math.sqrt(n);i++){
if(p[i]){
if(n%i==0){
cnt++;
}
if(cnt==2||n%(i*i)==0){
ans="YES";
break;
}
}
}
System.out.println(ans);
}
}
}
0