結果

問題 No.300 平方数
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-09 04:03:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 1,038 bytes
コンパイル時間 3,540 ms
コンパイル使用メモリ 77,028 KB
実行使用メモリ 37,876 KB
最終ジャッジ日時 2024-04-17 12:11:02
合計ジャッジ時間 7,142 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
36,524 KB
testcase_01 AC 49 ms
36,660 KB
testcase_02 AC 47 ms
36,676 KB
testcase_03 AC 46 ms
36,784 KB
testcase_04 AC 49 ms
36,816 KB
testcase_05 AC 46 ms
37,204 KB
testcase_06 AC 47 ms
36,572 KB
testcase_07 AC 47 ms
36,940 KB
testcase_08 AC 46 ms
36,916 KB
testcase_09 AC 49 ms
36,952 KB
testcase_10 AC 48 ms
36,668 KB
testcase_11 AC 47 ms
36,556 KB
testcase_12 AC 48 ms
37,012 KB
testcase_13 AC 66 ms
37,692 KB
testcase_14 AC 49 ms
37,120 KB
testcase_15 AC 46 ms
36,644 KB
testcase_16 AC 49 ms
36,652 KB
testcase_17 AC 47 ms
37,096 KB
testcase_18 AC 47 ms
36,900 KB
testcase_19 AC 46 ms
36,876 KB
testcase_20 AC 46 ms
37,096 KB
testcase_21 AC 48 ms
36,944 KB
testcase_22 AC 46 ms
36,652 KB
testcase_23 AC 48 ms
37,020 KB
testcase_24 AC 51 ms
36,568 KB
testcase_25 AC 72 ms
37,688 KB
testcase_26 AC 53 ms
36,796 KB
testcase_27 AC 51 ms
37,200 KB
testcase_28 AC 75 ms
37,692 KB
testcase_29 AC 59 ms
36,804 KB
testcase_30 AC 48 ms
36,984 KB
testcase_31 AC 50 ms
37,024 KB
testcase_32 AC 54 ms
37,104 KB
testcase_33 AC 54 ms
37,008 KB
testcase_34 AC 64 ms
37,876 KB
testcase_35 AC 59 ms
37,196 KB
testcase_36 AC 55 ms
36,556 KB
testcase_37 AC 54 ms
36,676 KB
testcase_38 AC 50 ms
36,696 KB
testcase_39 AC 48 ms
36,572 KB
testcase_40 AC 47 ms
37,000 KB
testcase_41 AC 51 ms
36,548 KB
testcase_42 AC 48 ms
36,552 KB
testcase_43 AC 51 ms
36,688 KB
testcase_44 AC 49 ms
36,876 KB
testcase_45 AC 50 ms
36,668 KB
権限があれば一括ダウンロードができます

ソースコード

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 nd = Long.parseLong(nStr);
    long n = nd;

    long[] factor = new long[10];
    int[] count = new int[10];

    int index = 0;

    while(n != 1 && n % 2 == 0){
      if(n % 2 == 0){
        factor[index] = 2;
        while (n % 2 == 0){
          count[index]++;
          n /= 2;
        }
        index++;
      }
    }


    for (long i = 3; i * i <= n; i += 2){
      if (n % i == 0){
        factor[index] = i;
        while(n % i == 0){
          count[index]++;
          n /= i;
        }
        index++;
      }
    }


    if (index == 0){
      System.out.println(nd);
      return;
    }

    long answer = 1;
    for (int i = 0; i < index; i ++){
      if(count[i] % 2 == 1){
        answer *= factor[i];
      }
    }
    System.out.println(answer * n);
  }
}
0