結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー tentententen
提出日時 2021-07-26 14:40:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 452 ms / 2,000 ms
コード長 2,107 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 77,752 KB
実行使用メモリ 66,112 KB
最終ジャッジ日時 2024-04-14 05:40:50
合計ジャッジ時間 14,258 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 452 ms
61,916 KB
testcase_01 AC 436 ms
65,436 KB
testcase_02 AC 449 ms
65,492 KB
testcase_03 AC 419 ms
61,800 KB
testcase_04 AC 435 ms
66,112 KB
testcase_05 AC 436 ms
65,340 KB
testcase_06 AC 417 ms
61,880 KB
testcase_07 AC 439 ms
62,200 KB
testcase_08 AC 433 ms
66,112 KB
testcase_09 AC 417 ms
62,204 KB
testcase_10 AC 319 ms
57,252 KB
testcase_11 AC 400 ms
65,384 KB
testcase_12 AC 380 ms
65,640 KB
testcase_13 AC 388 ms
65,260 KB
testcase_14 AC 389 ms
65,648 KB
testcase_15 AC 392 ms
65,340 KB
testcase_16 AC 392 ms
65,392 KB
testcase_17 AC 382 ms
65,424 KB
testcase_18 AC 396 ms
65,556 KB
testcase_19 AC 81 ms
51,224 KB
testcase_20 AC 83 ms
51,172 KB
testcase_21 AC 81 ms
51,272 KB
testcase_22 AC 82 ms
51,436 KB
testcase_23 AC 81 ms
51,356 KB
testcase_24 AC 88 ms
51,176 KB
testcase_25 AC 82 ms
51,268 KB
testcase_26 AC 90 ms
51,216 KB
testcase_27 AC 79 ms
51,396 KB
testcase_28 AC 53 ms
50,416 KB
testcase_29 AC 53 ms
50,364 KB
testcase_30 AC 53 ms
50,020 KB
testcase_31 AC 53 ms
50,444 KB
testcase_32 AC 53 ms
50,180 KB
testcase_33 AC 53 ms
50,528 KB
testcase_34 AC 53 ms
50,504 KB
testcase_35 AC 53 ms
50,496 KB
testcase_36 AC 54 ms
50,408 KB
testcase_37 AC 53 ms
50,164 KB
testcase_38 AC 54 ms
50,616 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};
        int[][] counts = new int[32][primes.length];
        for (int i = 2; i <= 31; i++) {
            int x = i;
            for (int j = 0; j < primes.length && x > 1; j++) {
                while (x % primes[j] == 0) {
                    x /= primes[j];
                    counts[i][j]++;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            long x = sc.nextLong();
            long y = x;
            int[] base = new int[primes.length];
            long target = 1;
            for (int j = 0; j < primes.length; j++) {
                while (y % primes[j] == 0) {
                    base[j]++;
                    y /= primes[j];
                }
                target *= base[j] + 1;
            }
            long ans = Long.MAX_VALUE;
            for (int j = 2; j <= 31; j++) {
                long tmp = 1;
                for (int k = 0; k < primes.length; k++) {
                    tmp *= base[k] + counts[j][k] + 1;
                }
                if (target * 2 == tmp) {
                    ans = j;
                    break;
                }
            }
            sb.append(x * ans).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