結果
問題 |
No.1611 Minimum Multiple with Double Divisors
|
ユーザー |
![]() |
提出日時 | 2021-07-26 10:03:27 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,636 bytes |
コンパイル時間 | 3,750 ms |
コンパイル使用メモリ | 77,456 KB |
実行使用メモリ | 53,292 KB |
最終ジャッジ日時 | 2024-07-21 22:45:32 |
合計ジャッジ時間 | 14,838 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 28 |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] primes = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { long x = sc.nextLong(); long y = x; long ans = Long.MAX_VALUE; for (int j = 0; j < primes.length; j++) { int count = 0; while (y % primes[j] == 0) { count++; y /= primes[j]; } if (count == 0) { if (ans > primes[j]) { ans = primes[j]; } break; } else { ans = Math.min(ans, (long)Math.pow(primes[j], count + 1)); } } sb.append(ans * x).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }