結果

問題 No.300 平方数
ユーザー htensaihtensai
提出日時 2019-11-22 19:19:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 780 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 77,304 KB
実行使用メモリ 41,984 KB
最終ジャッジ日時 2024-04-19 10:20:09
合計ジャッジ時間 10,015 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,392 KB
testcase_01 AC 131 ms
41,496 KB
testcase_02 AC 131 ms
41,448 KB
testcase_03 AC 134 ms
41,652 KB
testcase_04 AC 135 ms
41,384 KB
testcase_05 AC 132 ms
41,452 KB
testcase_06 AC 131 ms
41,600 KB
testcase_07 AC 134 ms
41,500 KB
testcase_08 AC 132 ms
41,260 KB
testcase_09 AC 132 ms
41,608 KB
testcase_10 AC 133 ms
41,556 KB
testcase_11 AC 133 ms
41,876 KB
testcase_12 AC 132 ms
41,728 KB
testcase_13 AC 150 ms
41,732 KB
testcase_14 AC 135 ms
41,072 KB
testcase_15 AC 131 ms
41,600 KB
testcase_16 AC 132 ms
41,500 KB
testcase_17 AC 133 ms
41,984 KB
testcase_18 AC 135 ms
41,264 KB
testcase_19 AC 132 ms
41,472 KB
testcase_20 AC 133 ms
41,324 KB
testcase_21 AC 131 ms
41,364 KB
testcase_22 AC 132 ms
41,308 KB
testcase_23 AC 144 ms
41,280 KB
testcase_24 AC 140 ms
41,404 KB
testcase_25 AC 145 ms
41,532 KB
testcase_26 AC 141 ms
41,600 KB
testcase_27 AC 146 ms
41,456 KB
testcase_28 AC 142 ms
41,580 KB
testcase_29 AC 147 ms
41,640 KB
testcase_30 AC 133 ms
41,092 KB
testcase_31 AC 137 ms
41,736 KB
testcase_32 AC 133 ms
41,592 KB
testcase_33 AC 144 ms
41,596 KB
testcase_34 AC 147 ms
41,512 KB
testcase_35 AC 142 ms
41,544 KB
testcase_36 AC 151 ms
41,528 KB
testcase_37 AC 139 ms
41,180 KB
testcase_38 AC 131 ms
41,288 KB
testcase_39 AC 130 ms
41,384 KB
testcase_40 AC 136 ms
41,352 KB
testcase_41 AC 139 ms
41,480 KB
testcase_42 AC 133 ms
41,436 KB
testcase_43 AC 133 ms
41,532 KB
testcase_44 AC 133 ms
41,540 KB
testcase_45 AC 131 ms
41,332 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