結果
| 問題 | No.300 平方数 |
| コンテスト | |
| ユーザー |
kenji_shioya
|
| 提出日時 | 2016-06-09 04:03:45 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 1,000 ms |
| コード長 | 1,038 bytes |
| コンパイル時間 | 3,579 ms |
| コンパイル使用メモリ | 77,140 KB |
| 実行使用メモリ | 37,932 KB |
| 最終ジャッジ日時 | 2024-10-09 06:12:48 |
| 合計ジャッジ時間 | 7,644 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
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);
}
}
kenji_shioya