結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー merlinmerlin
提出日時 2021-07-21 23:12:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 740 ms / 2,000 ms
コード長 1,504 bytes
コンパイル時間 2,316 ms
コンパイル使用メモリ 81,516 KB
実行使用メモリ 71,244 KB
最終ジャッジ日時 2024-04-14 05:25:25
合計ジャッジ時間 17,144 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 612 ms
65,584 KB
testcase_01 AC 449 ms
64,396 KB
testcase_02 AC 556 ms
70,272 KB
testcase_03 AC 555 ms
69,868 KB
testcase_04 AC 578 ms
71,244 KB
testcase_05 AC 603 ms
70,808 KB
testcase_06 AC 572 ms
70,980 KB
testcase_07 AC 570 ms
68,680 KB
testcase_08 AC 740 ms
70,192 KB
testcase_09 AC 558 ms
69,944 KB
testcase_10 AC 352 ms
66,220 KB
testcase_11 AC 391 ms
67,220 KB
testcase_12 AC 390 ms
66,976 KB
testcase_13 AC 390 ms
67,320 KB
testcase_14 AC 385 ms
67,728 KB
testcase_15 AC 390 ms
66,780 KB
testcase_16 AC 380 ms
66,588 KB
testcase_17 AC 366 ms
66,796 KB
testcase_18 AC 388 ms
67,408 KB
testcase_19 AC 150 ms
57,764 KB
testcase_20 AC 153 ms
57,836 KB
testcase_21 AC 140 ms
57,768 KB
testcase_22 AC 152 ms
57,540 KB
testcase_23 AC 145 ms
57,756 KB
testcase_24 AC 150 ms
57,552 KB
testcase_25 AC 157 ms
57,696 KB
testcase_26 AC 138 ms
57,552 KB
testcase_27 AC 151 ms
57,760 KB
testcase_28 AC 109 ms
54,176 KB
testcase_29 AC 123 ms
54,116 KB
testcase_30 AC 126 ms
54,408 KB
testcase_31 AC 118 ms
54,212 KB
testcase_32 AC 116 ms
54,432 KB
testcase_33 AC 119 ms
54,460 KB
testcase_34 AC 111 ms
54,444 KB
testcase_35 AC 120 ms
54,424 KB
testcase_36 AC 115 ms
54,292 KB
testcase_37 AC 121 ms
54,396 KB
testcase_38 AC 121 ms
54,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();

        int N=500000,pr[]=new int[N+1],i,j;
        ArrayList<Integer> p=new ArrayList<>();
        for(i=2;i<=N;i++)
        if(pr[i]==0)
        {
            p.add(i);
            for(j=i;j<=N;j+=i) pr[j]=i;
        }

        int t=Integer.parseInt(bu.readLine());
        while(t-->0)
        {
            long n=Long.parseLong(bu.readLine());
            long sm=-1; int fac=1,c;
            HashMap<Integer,Integer> hm=new HashMap<>();

            for(int x:p)
            if(n%x!=0) {sm=x; break;}
            else
            {
                long y=n; c=0;
                while(y%x==0) {y/=x; c++;}
                fac*=c+1;
                hm.put(x,c);
            }

            i=2;
            while(i<sm)
            {
                int x=i,fa2=fac;
                while(x!=1)
                {
                    int cn=0,pri=pr[x];
                    while(x%pri==0) {x/=pri; cn++;}
                    fa2/=hm.getOrDefault(pri,0)+1;
                    fa2*=cn+1+hm.getOrDefault(pri,0);
                }
                //System.out.println(i+" "+fa2);
                if(fa2==2*fac) {sm=i; break;}
                i++;
            }
            sm*=n;
            sb.append(sm+"\n");
        }
        System.out.print(sb);
    }
}
0