結果

問題 No.414 衝動
ユーザー TatsuDXTatsuDX
提出日時 2016-09-03 17:21:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 178 ms / 1,000 ms
コード長 657 bytes
コンパイル時間 3,832 ms
コンパイル使用メモリ 77,020 KB
実行使用メモリ 57,228 KB
最終ジャッジ日時 2024-04-27 08:25:18
合計ジャッジ時間 6,188 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
57,116 KB
testcase_01 AC 126 ms
53,740 KB
testcase_02 AC 178 ms
57,068 KB
testcase_03 AC 169 ms
56,880 KB
testcase_04 AC 132 ms
54,248 KB
testcase_05 AC 131 ms
53,752 KB
testcase_06 AC 133 ms
54,284 KB
testcase_07 AC 142 ms
53,868 KB
testcase_08 AC 130 ms
53,764 KB
testcase_09 AC 167 ms
57,228 KB
testcase_10 AC 137 ms
54,348 KB
testcase_11 AC 157 ms
57,084 KB
testcase_12 AC 142 ms
57,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		boolean[] b = new boolean[1000000];
		b[0] = true;
		b[1] = true;
		for(int i = 2; i < 1000; i++){
			if(!b[i]){
				for(int j = i*i; j < 100000; j+=i){
					b[j] = true;
				}
			}
		}
		long n = sc.nextLong();
		if(n < 1000000 && !b[(int)n]){
			System.out.println(1 + " " + n);
		} else if(n%2 == 0){
			System.out.println(2 + " " + n/2);
		} else {
			for(int i = 3; i < 1000000; i+=2){
				if(!b[i] && n%i == 0){
					System.out.println(i + " " + n/i);
					return;
				}
			}
			System.out.println(1 + " " + n);
		}
	}
}
0