結果

問題 No.300 平方数
ユーザー tentententen
提出日時 2023-07-27 14:56:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 76 ms / 1,000 ms
コード長 1,921 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 84,632 KB
実行使用メモリ 51,728 KB
最終ジャッジ日時 2024-04-15 02:32:28
合計ジャッジ時間 5,909 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,484 KB
testcase_01 AC 49 ms
50,332 KB
testcase_02 AC 50 ms
50,516 KB
testcase_03 AC 49 ms
50,480 KB
testcase_04 AC 51 ms
50,332 KB
testcase_05 AC 50 ms
50,020 KB
testcase_06 AC 49 ms
50,480 KB
testcase_07 AC 50 ms
50,420 KB
testcase_08 AC 50 ms
50,428 KB
testcase_09 AC 51 ms
50,416 KB
testcase_10 AC 51 ms
50,440 KB
testcase_11 AC 51 ms
50,488 KB
testcase_12 AC 52 ms
50,420 KB
testcase_13 AC 75 ms
51,572 KB
testcase_14 AC 50 ms
50,432 KB
testcase_15 AC 52 ms
50,268 KB
testcase_16 AC 50 ms
50,200 KB
testcase_17 AC 49 ms
50,152 KB
testcase_18 AC 50 ms
50,468 KB
testcase_19 AC 50 ms
50,412 KB
testcase_20 AC 51 ms
50,480 KB
testcase_21 AC 49 ms
50,212 KB
testcase_22 AC 49 ms
50,396 KB
testcase_23 AC 53 ms
50,304 KB
testcase_24 AC 58 ms
50,400 KB
testcase_25 AC 71 ms
51,696 KB
testcase_26 AC 63 ms
51,104 KB
testcase_27 AC 58 ms
50,872 KB
testcase_28 AC 72 ms
51,728 KB
testcase_29 AC 67 ms
51,532 KB
testcase_30 AC 53 ms
50,508 KB
testcase_31 AC 54 ms
50,552 KB
testcase_32 AC 52 ms
50,488 KB
testcase_33 AC 76 ms
51,156 KB
testcase_34 AC 71 ms
51,696 KB
testcase_35 AC 67 ms
51,612 KB
testcase_36 AC 61 ms
50,980 KB
testcase_37 AC 62 ms
50,932 KB
testcase_38 AC 49 ms
50,204 KB
testcase_39 AC 50 ms
50,092 KB
testcase_40 AC 50 ms
50,480 KB
testcase_41 AC 57 ms
50,512 KB
testcase_42 AC 56 ms
50,236 KB
testcase_43 AC 50 ms
50,348 KB
testcase_44 AC 50 ms
50,424 KB
testcase_45 AC 50 ms
50,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        HashSet<Long> exist = new HashSet<>();
        for (long i = 2; i <= Math.sqrt(n); i++) {
            while (n % i == 0) {
                if (exist.contains(i)) {
                    exist.remove(i);
                } else {
                    exist.add(i);
                }
                n /= i;
            }
        }
        exist.add(n);
        long ans = 1;
        for (long x : exist) {
            ans *= x;
        }
        System.out.println(ans);
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0