結果

問題 No.300 平方数
ユーザー tentententen
提出日時 2020-10-07 09:14:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 764 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 73,300 KB
実行使用メモリ 56,736 KB
最終ジャッジ日時 2023-09-27 09:08:41
合計ジャッジ時間 9,388 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,708 KB
testcase_01 AC 114 ms
55,872 KB
testcase_02 AC 115 ms
56,336 KB
testcase_03 AC 115 ms
56,160 KB
testcase_04 AC 114 ms
55,752 KB
testcase_05 AC 115 ms
55,952 KB
testcase_06 AC 114 ms
56,476 KB
testcase_07 AC 116 ms
55,872 KB
testcase_08 AC 119 ms
55,732 KB
testcase_09 AC 120 ms
56,536 KB
testcase_10 AC 117 ms
56,216 KB
testcase_11 AC 113 ms
55,920 KB
testcase_12 AC 114 ms
56,316 KB
testcase_13 AC 129 ms
56,152 KB
testcase_14 AC 116 ms
55,776 KB
testcase_15 AC 118 ms
56,192 KB
testcase_16 AC 116 ms
55,792 KB
testcase_17 AC 122 ms
55,988 KB
testcase_18 AC 114 ms
55,644 KB
testcase_19 AC 116 ms
55,744 KB
testcase_20 AC 117 ms
55,936 KB
testcase_21 AC 117 ms
55,824 KB
testcase_22 AC 116 ms
56,212 KB
testcase_23 AC 124 ms
55,948 KB
testcase_24 AC 118 ms
55,856 KB
testcase_25 AC 129 ms
56,136 KB
testcase_26 AC 121 ms
55,908 KB
testcase_27 AC 121 ms
55,900 KB
testcase_28 AC 130 ms
53,920 KB
testcase_29 AC 130 ms
56,124 KB
testcase_30 AC 114 ms
55,948 KB
testcase_31 AC 116 ms
56,228 KB
testcase_32 AC 113 ms
56,300 KB
testcase_33 AC 116 ms
55,948 KB
testcase_34 AC 130 ms
56,016 KB
testcase_35 AC 124 ms
55,728 KB
testcase_36 AC 120 ms
55,868 KB
testcase_37 AC 119 ms
56,156 KB
testcase_38 AC 109 ms
55,536 KB
testcase_39 AC 110 ms
55,936 KB
testcase_40 AC 114 ms
56,188 KB
testcase_41 AC 120 ms
56,032 KB
testcase_42 AC 111 ms
55,816 KB
testcase_43 AC 112 ms
56,736 KB
testcase_44 AC 114 ms
55,812 KB
testcase_45 AC 112 ms
55,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		HashMap<Long, Integer> map = new HashMap<>();
		for (long i = 2; i <= Math.sqrt(x); i++) {
		    while (x % i == 0) {
		        if (map.containsKey(i)) {
		            map.put(i, map.get(i) + 1);
		        } else {
		            map.put(i, 1);
		        }
		        x /= i;
		    }
		}
		if (x != 1) {
		    if (map.containsKey(x)) {
		        map.put(x, map.get(x) + 1);
		    } else {
		        map.put(x, 1);
		    }
		}
		long ans = 1;
		for (Map.Entry<Long, Integer> entry : map.entrySet()) {
		    if (entry.getValue() % 2 == 1) {
		        ans *= entry.getKey();
		    }
		}
		System.out.println(ans);
	}
}
0