結果

問題 No.2318 Phys Bone Maker
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-03 22:52:38
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 3,400 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 108,800 KB
実行使用メモリ 435,456 KB
最終ジャッジ日時 2024-04-21 21:39:11
合計ジャッジ時間 27,674 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
19,072 KB
testcase_01 AC 34 ms
18,944 KB
testcase_02 TLE -
testcase_03 AC 55 ms
18,944 KB
testcase_04 AC 64 ms
19,072 KB
testcase_05 AC 51 ms
19,328 KB
testcase_06 AC 53 ms
18,816 KB
testcase_07 AC 41 ms
19,072 KB
testcase_08 AC 70 ms
19,200 KB
testcase_09 AC 56 ms
18,944 KB
testcase_10 AC 83 ms
19,200 KB
testcase_11 AC 92 ms
19,072 KB
testcase_12 AC 132 ms
18,944 KB
testcase_13 AC 109 ms
19,584 KB
testcase_14 AC 69 ms
19,072 KB
testcase_15 AC 67 ms
18,944 KB
testcase_16 AC 56 ms
18,944 KB
testcase_17 AC 70 ms
18,944 KB
testcase_18 AC 121 ms
19,072 KB
testcase_19 AC 49 ms
18,816 KB
testcase_20 AC 60 ms
19,200 KB
testcase_21 AC 52 ms
18,944 KB
testcase_22 AC 52 ms
18,944 KB
testcase_23 AC 54 ms
19,328 KB
testcase_24 AC 71 ms
19,072 KB
testcase_25 AC 74 ms
19,072 KB
testcase_26 AC 74 ms
19,200 KB
testcase_27 AC 60 ms
19,072 KB
testcase_28 AC 51 ms
18,816 KB
testcase_29 AC 47 ms
19,072 KB
testcase_30 AC 46 ms
19,072 KB
testcase_31 AC 93 ms
19,200 KB
testcase_32 AC 65 ms
19,200 KB
testcase_33 AC 33 ms
18,944 KB
testcase_34 AC 72 ms
18,944 KB
testcase_35 AC 349 ms
65,792 KB
testcase_36 AC 1,326 ms
222,464 KB
testcase_37 AC 1,370 ms
224,512 KB
testcase_38 AC 1,560 ms
226,688 KB
testcase_39 AC 2,028 ms
321,536 KB
testcase_40 AC 2,110 ms
323,328 KB
testcase_41 AC 2,407 ms
366,592 KB
testcase_42 AC 2,540 ms
370,944 KB
testcase_43 AC 126 ms
19,584 KB
testcase_44 AC 717 ms
59,904 KB
testcase_45 AC 653 ms
58,240 KB
testcase_46 AC 2,830 ms
376,192 KB
testcase_47 AC 63 ms
19,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = long.Parse(ReadLine());

        var plist = PList(n);
        var map = new List<long>[plist.Count];
        for (var i = 0; i < map.Length; ++i) map[i] = PList(plist[i]);
        var rev = new Dictionary<long, int>();
        for (var i = 0; i < plist.Count; ++i) rev[plist[i]] = i;

        var dic = PDiv(n);
        var primes = new List<long>(dic.Select(kv => kv.Key));
        primes.Sort();
        var pcntmap = new int[plist.Count][];
        for (var i = 0; i < pcntmap.Length; ++i)
        {
            pcntmap[i] = new int[primes.Count];
            for (var j = 0; j < pcntmap[i].Length; ++j)
            {
                var tmp = plist[i];
                while (tmp % primes[j] == 0)
                {
                    ++pcntmap[i][j];
                    tmp /= primes[j];
                }
            }
        }
        // WriteLine("p: " + string.Join(" ", primes));
        // WriteLine(string.Join("\n", pcntmap.Select((pi, i) => $"{plist[i]}: {string.Join(" ", pi)}")));

        var dp = new long[plist.Count][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[plist.Count];
        dp[0][0] = 1;
        var mod = 998_244_353;
        for (var m = 0; m + 1 < dp.Length; ++m) for (var i = 0; i + 1 < dp[m].Length; ++i)
        {
            // if (m % 100 == 0 && i == 0) WriteLine($"m = {m}");
            if (dp[m][i] == 0) continue;
            foreach (var r in map[map.Length - 1 - i])
            {
                if (r == 1) continue;
                var next = rev[plist[i] * r];
                var add = dp[m][i];
                for (var q = 0; q < primes.Count; ++q)
                {
                    if (pcntmap[i][q] == pcntmap[next][q]) add = add * (pcntmap[i][q] + 1);
                }
                // WriteLine($"{m} {i} to {next} ({plist[i]} to {plist[i]} * {r}) : add {add}");
                dp[m + 1][next] = (dp[m + 1][next] + add % mod) % mod;
            }
        }
        var ans = 0L;
        for (var i = 1; i < dp.Length; ++i) ans = (ans + dp[i][dp[i].Length - 1]) % mod;
        WriteLine(ans);
    }
    static List<long> PList(long n)
    {
        var list = new List<long>();
        var rev = new List<long>();
        for (var i = 1L; i * i <= n; ++i)
        {
            if (n % i == 0)
            {
                list.Add(i);
                if (i * i < n) rev.Add(n / i);
            }
        }
        rev.Reverse();
        list.AddRange(rev);
        return list;
    }
    static Dictionary<long, int> PDiv(long n)
    {
        var dic = new Dictionary<long, int>();
        var tmp = n;
        while (tmp % 2 == 0)
        {
            tmp /= 2;
            if (dic.ContainsKey(2)) ++dic[2];
            else dic.Add(2, 1);
        }
        for (var p = 3L; p * p <= n; p += 2)
        {
            while (tmp % p == 0)
            {
                tmp /= p;
                if (dic.ContainsKey(p)) ++dic[p];
                else dic.Add(p, 1);
            }
            if (tmp == 1) break;
        }
        if (tmp > 1) dic.Add(tmp, 1);
        return dic;
    }
}
0