結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー merlinmerlin
提出日時 2021-07-21 21:39:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 850 bytes
コンパイル時間 5,419 ms
コンパイル使用メモリ 86,176 KB
実行使用メモリ 67,916 KB
最終ジャッジ日時 2023-09-24 16:08:57
合計ジャッジ時間 14,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 397 ms
64,868 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 WA -
testcase_29 AC 109 ms
54,488 KB
testcase_30 AC 99 ms
53,812 KB
testcase_31 AC 110 ms
54,996 KB
testcase_32 AC 96 ms
53,800 KB
testcase_33 AC 102 ms
55,012 KB
testcase_34 AC 93 ms
53,800 KB
testcase_35 WA -
testcase_36 AC 96 ms
53,684 KB
testcase_37 AC 95 ms
53,724 KB
testcase_38 AC 107 ms
54,748 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=n;
            for(int x:p)
            if(n%x!=0) {sm=Math.min(sm,x); break;}
            else if(n%(1l*x*x)!=0) sm=Math.min(sm,1l*x*x);
            sm*=n;
            sb.append(sm+"\n");
        }
        System.out.print(sb);
    }
}
0