結果

問題 No.414 衝動
ユーザー mosmos_21mosmos_21
提出日時 2017-06-23 17:46:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 344 ms / 1,000 ms
コード長 700 bytes
コンパイル時間 2,976 ms
コンパイル使用メモリ 83,504 KB
実行使用メモリ 80,884 KB
最終ジャッジ日時 2024-04-27 08:31:13
合計ジャッジ時間 6,558 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 272 ms
78,124 KB
testcase_01 AC 172 ms
54,736 KB
testcase_02 AC 175 ms
55,304 KB
testcase_03 AC 344 ms
80,884 KB
testcase_04 AC 308 ms
80,616 KB
testcase_05 AC 308 ms
80,008 KB
testcase_06 AC 318 ms
79,940 KB
testcase_07 AC 151 ms
54,084 KB
testcase_08 AC 248 ms
67,972 KB
testcase_09 AC 328 ms
80,492 KB
testcase_10 AC 149 ms
54,220 KB
testcase_11 AC 193 ms
57,100 KB
testcase_12 AC 191 ms
57,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
       long n = in.nextLong();
       boolean[] pr = new boolean[(int)Math.sqrt(n) + 1];
       ArrayList<Integer> list = new ArrayList<>();
       for(int i = 2; i < pr.length; i++){
           if(pr[i]) continue;
           for(int j = 2 * i; j < pr.length; j += i){
               pr[i] = true;
           }
           list.add(i);
       }
       for(int i : list){
           if(n % i == 0){
               System.out.println(i + " " + n / i);
               return;
           }
       }
       System.out.println("1 " + n);
    }
}
0