結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-21 23:39:09
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 857 ms / 2,000 ms
コード長 1,573 bytes
コンパイル時間 14,552 ms
コンパイル使用メモリ 157,888 KB
実行使用メモリ 179,176 KB
最終ジャッジ日時 2024-02-21 23:39:37
合計ジャッジ時間 19,058 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 857 ms
68,652 KB
testcase_01 AC 361 ms
68,804 KB
testcase_02 AC 357 ms
68,688 KB
testcase_03 AC 355 ms
68,700 KB
testcase_04 AC 360 ms
68,692 KB
testcase_05 AC 359 ms
68,692 KB
testcase_06 AC 359 ms
68,688 KB
testcase_07 AC 359 ms
68,560 KB
testcase_08 AC 357 ms
68,696 KB
testcase_09 AC 358 ms
68,704 KB
testcase_10 AC 239 ms
62,244 KB
testcase_11 AC 252 ms
68,496 KB
testcase_12 AC 248 ms
68,360 KB
testcase_13 AC 250 ms
68,360 KB
testcase_14 AC 249 ms
68,232 KB
testcase_15 AC 251 ms
68,228 KB
testcase_16 AC 249 ms
68,236 KB
testcase_17 AC 250 ms
68,360 KB
testcase_18 AC 255 ms
68,280 KB
testcase_19 AC 85 ms
33,444 KB
testcase_20 AC 83 ms
33,572 KB
testcase_21 AC 83 ms
33,572 KB
testcase_22 AC 82 ms
33,572 KB
testcase_23 AC 86 ms
33,572 KB
testcase_24 AC 82 ms
33,572 KB
testcase_25 AC 82 ms
33,572 KB
testcase_26 AC 83 ms
33,572 KB
testcase_27 AC 82 ms
33,572 KB
testcase_28 AC 80 ms
32,804 KB
testcase_29 AC 80 ms
32,804 KB
testcase_30 AC 80 ms
32,804 KB
testcase_31 AC 80 ms
32,804 KB
testcase_32 AC 80 ms
32,804 KB
testcase_33 AC 80 ms
32,804 KB
testcase_34 AC 79 ms
32,804 KB
testcase_35 AC 80 ms
32,804 KB
testcase_36 AC 80 ms
32,804 KB
testcase_37 AC 80 ms
32,804 KB
testcase_38 AC 80 ms
179,176 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (103 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new long[t];
        for (var u = 0; u < t; ++u)
        {
            var x = long.Parse(ReadLine());
            ans[u] = Mul(x);
        }
        WriteLine(string.Join("\n", ans));
    }
    static long Mul(long x)
    {
        var plist = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
        var countb = Enumerable.Repeat(1, plist.Length).ToArray();
        for (var i = 0; i < plist.Length; ++i)
        {
            var xi = x;
            while (xi % plist[i] == 0)
            {
                ++countb[i];
                xi /= plist[i];
            }
        }
        var allb = 1;
        foreach (var c in countb) allb *= c;
        for (var m = 2; m <= 31; ++m)
        {
            var count = (int[]) countb.Clone();
            var tmp = m;
            for (var i = 0; i < plist.Length; ++i)
            {
                while (tmp % plist[i] == 0)
                {
                    ++count[i];
                    tmp /= plist[i];
                }
            }
            var all = 1;
            foreach (var c in count) all *= c;
            if (allb * 2 == all) return x * m;
        }
        return -1;
    }
}
0