結果

問題 No.36 素数が嫌い!
ユーザー shinwisteriashinwisteria
提出日時 2017-04-02 21:26:34
言語 Java19
(openjdk 21)
結果
AC  
実行時間 453 ms / 5,000 ms
コード長 814 bytes
コンパイル時間 3,609 ms
コンパイル使用メモリ 75,944 KB
実行使用メモリ 97,696 KB
最終ジャッジ日時 2023-09-09 07:57:28
合計ジャッジ時間 12,539 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
75,296 KB
testcase_01 AC 372 ms
87,608 KB
testcase_02 AC 126 ms
55,788 KB
testcase_03 AC 128 ms
55,864 KB
testcase_04 AC 126 ms
55,656 KB
testcase_05 AC 130 ms
55,744 KB
testcase_06 AC 133 ms
55,772 KB
testcase_07 AC 135 ms
55,760 KB
testcase_08 AC 129 ms
55,848 KB
testcase_09 AC 131 ms
55,768 KB
testcase_10 AC 130 ms
55,892 KB
testcase_11 AC 194 ms
72,920 KB
testcase_12 AC 449 ms
95,648 KB
testcase_13 AC 451 ms
95,916 KB
testcase_14 AC 309 ms
81,332 KB
testcase_15 AC 127 ms
55,892 KB
testcase_16 AC 125 ms
55,864 KB
testcase_17 AC 126 ms
56,000 KB
testcase_18 AC 126 ms
55,952 KB
testcase_19 AC 210 ms
73,084 KB
testcase_20 AC 453 ms
95,944 KB
testcase_21 AC 362 ms
87,296 KB
testcase_22 AC 386 ms
87,296 KB
testcase_23 AC 251 ms
77,228 KB
testcase_24 AC 281 ms
79,428 KB
testcase_25 AC 273 ms
77,752 KB
testcase_26 AC 309 ms
81,048 KB
testcase_27 AC 398 ms
91,552 KB
testcase_28 AC 295 ms
81,448 KB
testcase_29 AC 441 ms
97,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.TreeSet;
public class Primehate {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s= new Scanner(System.in);
		long N = s.nextLong();
		s.close();
		int n = (int)Math.sqrt(N);
		int[] p = new int[n+1];
		TreeSet<Integer> prime = new TreeSet<>();
		long check = N;
		for(int i = 2;i <= n;i++){
			if(p[i] == 0){
				for(int j = 2;i*j <= n;j++){
					p[i*j] = 1;
				}
				if(N % i == 0){
					prime.add(i);
					check = N/i;
				}
			}
		}
		if(check == N){
			System.out.println("NO");
		}else{
			boolean tof = true;
			for(int i:prime){
				if(check % i == 0 && check != i){
					System.out.println("YES");
					tof = false;
					break;
				}
			}
			if(tof){
				System.out.println("NO");
			}
		}
		

	}

}
0