結果
| 問題 |
No.1063 ルートの計算 / Sqrt Calculation
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-06-04 13:27:29 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 738 bytes |
| コンパイル時間 | 3,288 ms |
| コンパイル使用メモリ | 88,636 KB |
| 実行使用メモリ | 55,000 KB |
| 最終ジャッジ日時 | 2024-11-28 19:59:19 |
| 合計ジャッジ時間 | 5,412 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 1 |
ソースコード
import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayDeque<Integer> stack = new ArrayDeque<>();
for (int i = 1; i < Math.sqrt(n); i++) {
if (n % i == 0) {
stack.push(n / i);
int x = n / i;
if ((int)(Math.sqrt(x)) * (int)(Math.sqrt(x)) == x) {
System.out.println((int)(Math.sqrt(x)) + " " + i);
return;
}
}
}
while (stack.size() > 0) {
int i = stack.pop();
int x = n / i;
if ((int)(Math.sqrt(x)) * (int)(Math.sqrt(x)) == x) {
System.out.println((int)(Math.sqrt(x)) + " " + i);
return;
}
}
}
}
htensai