結果
問題 | No.414 衝動 |
ユーザー |
![]() |
提出日時 | 2018-11-03 23:01:12 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 183 ms / 1,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 2,431 ms |
コンパイル使用メモリ | 82,416 KB |
実行使用メモリ | 55,224 KB |
最終ジャッジ日時 | 2024-11-15 09:21:10 |
合計ジャッジ時間 | 5,676 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
ソースコード
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;long b=1;for(long l:map.keySet()) {a=l;break;}for(long l:map.keySet()) {if(i==0) {b*=Math.pow(l, map.get(l)-1);i++;continue;}b*=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;}}