結果

問題 No.300 平方数
ユーザー nanophoto12nanophoto12
提出日時 2015-11-29 10:34:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 666 bytes
コンパイル時間 4,627 ms
コンパイル使用メモリ 70,852 KB
実行使用メモリ 57,852 KB
最終ジャッジ日時 2023-10-12 05:38:21
合計ジャッジ時間 9,200 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,324 KB
testcase_01 AC 117 ms
55,884 KB
testcase_02 AC 117 ms
55,344 KB
testcase_03 AC 116 ms
55,692 KB
testcase_04 AC 119 ms
55,364 KB
testcase_05 AC 118 ms
55,592 KB
testcase_06 AC 118 ms
55,640 KB
testcase_07 AC 120 ms
55,628 KB
testcase_08 AC 119 ms
55,364 KB
testcase_09 AC 117 ms
55,604 KB
testcase_10 AC 117 ms
55,568 KB
testcase_11 AC 119 ms
56,084 KB
testcase_12 AC 120 ms
55,652 KB
testcase_13 AC 134 ms
55,648 KB
testcase_14 AC 119 ms
55,616 KB
testcase_15 AC 119 ms
55,652 KB
testcase_16 AC 117 ms
55,552 KB
testcase_17 AC 119 ms
55,488 KB
testcase_18 AC 120 ms
55,624 KB
testcase_19 AC 119 ms
55,504 KB
testcase_20 AC 120 ms
55,516 KB
testcase_21 AC 120 ms
55,696 KB
testcase_22 AC 119 ms
55,436 KB
testcase_23 AC 124 ms
55,536 KB
testcase_24 AC 126 ms
55,660 KB
testcase_25 AC 134 ms
55,504 KB
testcase_26 AC 127 ms
55,536 KB
testcase_27 AC 126 ms
55,724 KB
testcase_28 AC 132 ms
55,616 KB
testcase_29 AC 131 ms
55,780 KB
testcase_30 AC 121 ms
55,364 KB
testcase_31 AC 122 ms
53,308 KB
testcase_32 AC 119 ms
55,644 KB
testcase_33 AC 127 ms
55,704 KB
testcase_34 AC 132 ms
55,592 KB
testcase_35 AC 131 ms
56,508 KB
testcase_36 AC 125 ms
55,660 KB
testcase_37 AC 127 ms
55,620 KB
testcase_38 AC 122 ms
55,512 KB
testcase_39 AC 121 ms
57,852 KB
testcase_40 AC 121 ms
55,608 KB
testcase_41 AC 128 ms
55,360 KB
testcase_42 AC 120 ms
55,800 KB
testcase_43 AC 120 ms
54,328 KB
testcase_44 AC 120 ms
55,652 KB
testcase_45 AC 120 ms
55,460 KB
権限があれば一括ダウンロードができます

ソースコード

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