結果

問題 No.300 平方数
ユーザー nanophoto12
提出日時 2015-11-29 10:34:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 149 ms / 1,000 ms
コード長 666 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 73,844 KB
実行使用メモリ 54,288 KB
最終ジャッジ日時 2024-09-14 05:04:34
合計ジャッジ時間 9,623 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final long X = sc.nextLong();

        long rest = X;
        long answer = 1;
        for(long i = 2; i * i <= rest; i++){
            int count = 0;
            while(rest % i == 0){
                rest /= i;
                count++;
            }

            if(count % 2 != 0){
                answer *= i;
            }
            //System.out.println(i + " : " + answer);
        }

        if(rest > 1){
            answer *= rest;
        }

        System.out.println(answer);
    }
}
0