結果

問題 No.300 平方数
ユーザー samplelpmassamplelpmas
提出日時 2017-04-20 18:47:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 563 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 74,236 KB
実行使用メモリ 54,016 KB
最終ジャッジ日時 2024-07-19 21:10:24
合計ジャッジ時間 8,575 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();

        long y = 1;

        for (long i = 2; (i * i) <= x; i++) {

            int factorCount = 0;

            while (x % i == 0) {

                x /= i;
                factorCount++;

            }

            if (factorCount % 2 != 0) {
                y *= i;
            }

        }

        if (x > 1) {
            y *= x;
        }

        System.out.println(y);

    }

}
0