結果

問題 No.414 衝動
ユーザー hhgfhn1hhgfhn1
提出日時 2018-11-03 22:59:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 86,084 KB
実行使用メモリ 55,212 KB
最終ジャッジ日時 2024-04-30 21:36:02
合計ジャッジ時間 5,129 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
54,984 KB
testcase_01 AC 142 ms
54,880 KB
testcase_02 AC 149 ms
55,048 KB
testcase_03 AC 158 ms
55,188 KB
testcase_04 WA -
testcase_05 AC 154 ms
55,008 KB
testcase_06 AC 155 ms
54,960 KB
testcase_07 AC 123 ms
55,044 KB
testcase_08 AC 139 ms
54,808 KB
testcase_09 AC 154 ms
54,848 KB
testcase_10 AC 130 ms
55,212 KB
testcase_11 AC 145 ms
55,076 KB
testcase_12 AC 148 ms
54,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		long m=scanner.nextLong();
		Map<Long,Integer>map=prime_fact(m);
		int i=0;
		long a=1;
		int b=1;
		for(long l:map.keySet()) {
			a=l;
			break;
		}
		for(long l:map.keySet()) {
			if(i==0) {
				b*=(int) Math.pow(l, map.get(l)-1);
				i++;
				continue;
			}
			b*=(int) Math.pow(l, map.get(l));
		}
		System.out.println(a+" "+b);
	}
	
	private static Map<Long, Integer> prime_fact(long n) {
		Map<Long, Integer> map = new TreeMap<>();
		double d = Math.sqrt(n);
		for (int i = 2; i <= d; i++) {
			int cnt = 0;
			while (n % i == 0) {
				n /= i;
				cnt++;
			}
			if (cnt != 0) {
				map.put((long) i, cnt);
			}
		}
		if (n != 1) {
			map.put(n, 1);
		}
		return map;
	}
}
0