結果

問題 No.300 平方数
ユーザー hhgfhn1hhgfhn1
提出日時 2018-11-03 18:35:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 74,636 KB
実行使用メモリ 58,364 KB
最終ジャッジ日時 2024-04-30 21:29:38
合計ジャッジ時間 8,906 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
54,392 KB
testcase_01 AC 112 ms
54,124 KB
testcase_02 AC 118 ms
55,320 KB
testcase_03 AC 110 ms
54,128 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 111 ms
54,176 KB
testcase_08 AC 112 ms
53,900 KB
testcase_09 AC 113 ms
54,024 KB
testcase_10 AC 118 ms
54,016 KB
testcase_11 AC 124 ms
54,264 KB
testcase_12 AC 125 ms
54,112 KB
testcase_13 WA -
testcase_14 AC 101 ms
52,460 KB
testcase_15 AC 130 ms
56,016 KB
testcase_16 WA -
testcase_17 AC 135 ms
58,364 KB
testcase_18 AC 118 ms
54,152 KB
testcase_19 AC 129 ms
56,168 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

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