結果

問題 No.36 素数が嫌い!
ユーザー uafr_cs
提出日時 2015-06-03 15:35:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 244 ms / 5,000 ms
コード長 882 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 75,428 KB
実行使用メモリ 41,764 KB
最終ジャッジ日時 2024-06-27 00:20:15
合計ジャッジ時間 8,119 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		
		if(N == 1){
			System.out.println("NO");
			return;
		}
		
		final int sqrt_N = (int)(Math.floor(Math.sqrt(N)));
		long cur_N = N;
		int types = 0, max_counts = 0;
		for(int i = 2; i <= sqrt_N; i++){
			int count = 0;
			while(cur_N % i == 0){
				count++;
				cur_N /= i;
			}
			
			max_counts = Math.max(max_counts, count);
			if(count != 0){
				types++;
			}
		}
		
		if(cur_N != 1){
			types++;
		}
		
		//System.out.println(cur_N + " " + types + " " + max_counts);
		
		if((types >= 3 || max_counts >= 3 || (types >= 2 && max_counts >= 2))){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		
	}
	
}
0