結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー tentententen
提出日時 2021-07-26 10:03:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,636 bytes
コンパイル時間 3,415 ms
コンパイル使用メモリ 74,324 KB
実行使用メモリ 67,164 KB
最終ジャッジ日時 2023-09-29 04:13:14
合計ジャッジ時間 16,348 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 425 ms
64,688 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 45 ms
49,300 KB
testcase_29 AC 46 ms
49,312 KB
testcase_30 AC 45 ms
49,272 KB
testcase_31 AC 44 ms
49,256 KB
testcase_32 AC 45 ms
49,320 KB
testcase_33 AC 46 ms
49,268 KB
testcase_34 AC 46 ms
49,416 KB
testcase_35 WA -
testcase_36 AC 43 ms
49,252 KB
testcase_37 AC 45 ms
49,268 KB
testcase_38 AC 45 ms
49,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
}
0