結果

問題 No.300 平方数
ユーザー hhgfhn1
提出日時 2018-11-03 18:35:58
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 74,092 KB
実行使用メモリ 58,856 KB
最終ジャッジ日時 2024-11-20 19:32:17
合計ジャッジ時間 9,126 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		long x=scanner.nextLong();
		int p[]=prime_fact(x);
		int ans=1;
		for(int i=1;i<p.length;i++) {
			if(p[i]%2==1) {
				ans*=i;
			}
		}
		System.out.println(ans);
	}

	private static int[] prime_fact(long x) {
		double d = Math.sqrt(x);
		int res[] = new int[(int) d + 1];
		for (int i = 2; i <= d; i++) {
			while (x % i == 0) {
				x /= i;
				res[i]++;
			}
		}
		return res;
	}
}
0