結果

問題 No.300 平方数
ユーザー scache
提出日時 2015-11-13 22:28:40
言語 Java
(openjdk 23)
結果
AC  
実行時間 177 ms / 1,000 ms
コード長 617 bytes
コンパイル時間 3,299 ms
コンパイル使用メモリ 74,744 KB
実行使用メモリ 54,352 KB
最終ジャッジ日時 2024-09-13 14:39:36
合計ジャッジ時間 12,464 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class Main299 {
    public static void main(String[] args) {
        new Main299();
    }

    public Main299() {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        System.out.println(solve(x));
    }

    public long solve(long x) {
        long res = 1;
        for (long i = 2; i * i < (10e+12) + 1; i++) {
            int count = 0;
            while (x % i == 0) {
                x /= i;
                count++;
            }

            res *= count % 2 == 1 ? i : 1;
        }

        return res * x;

    }
}
0