結果

問題 No.300 平方数
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-08 18:27:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 3,498 ms
コンパイル使用メモリ 75,716 KB
実行使用メモリ 53,248 KB
最終ジャッジ日時 2024-04-17 09:51:25
合計ジャッジ時間 7,918 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
37,032 KB
testcase_01 AC 54 ms
37,056 KB
testcase_02 AC 73 ms
37,936 KB
testcase_03 AC 54 ms
37,052 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 55 ms
36,900 KB
testcase_08 AC 54 ms
37,044 KB
testcase_09 AC 54 ms
36,684 KB
testcase_10 AC 53 ms
36,724 KB
testcase_11 AC 53 ms
37,120 KB
testcase_12 AC 54 ms
36,552 KB
testcase_13 WA -
testcase_14 AC 56 ms
36,884 KB
testcase_15 AC 72 ms
37,816 KB
testcase_16 AC 72 ms
37,844 KB
testcase_17 AC 79 ms
37,776 KB
testcase_18 AC 58 ms
37,168 KB
testcase_19 AC 70 ms
37,524 KB
testcase_20 WA -
testcase_21 AC 79 ms
37,864 KB
testcase_22 AC 74 ms
37,788 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 73 ms
37,952 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 72 ms
37,884 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Exercise68{
  public static void main (String[] args) throws IOException{

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String nStr = new String(in.readLine());

    long n = Long.parseLong(nStr);

    long sq = (long)Math.sqrt((double)n);

    HashMap<Long,Integer> factor = new HashMap<Long,Integer>();

    long answer = 1;

    for(long i = 2; i <= sq; i++){
      int count = 0;
      while (n % i == 0){
        n /= i;
        count++;
      }
      if(count > 0){
        factor.put(i, count);
      }
    }

    for (Map.Entry<Long,Integer> entry : factor.entrySet()){
      if(entry.getValue() % 2 == 1){
        answer *= entry.getKey();
      }
    }
    System.out.println(answer);
  }
}
0