結果

問題 No.1581 Multiple Sequence
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-29 23:35:20
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 551 ms / 2,000 ms
コード長 1,593 bytes
コンパイル時間 18,415 ms
コンパイル使用メモリ 158,636 KB
実行使用メモリ 212,312 KB
最終ジャッジ日時 2024-02-29 23:35:52
合計ジャッジ時間 29,160 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
31,524 KB
testcase_01 AC 62 ms
31,524 KB
testcase_02 AC 497 ms
62,300 KB
testcase_03 AC 478 ms
62,656 KB
testcase_04 AC 158 ms
44,324 KB
testcase_05 AC 521 ms
62,812 KB
testcase_06 AC 226 ms
51,492 KB
testcase_07 AC 149 ms
43,684 KB
testcase_08 AC 190 ms
47,396 KB
testcase_09 AC 480 ms
62,496 KB
testcase_10 AC 302 ms
61,372 KB
testcase_11 AC 103 ms
38,308 KB
testcase_12 AC 200 ms
48,804 KB
testcase_13 AC 67 ms
32,804 KB
testcase_14 AC 510 ms
62,656 KB
testcase_15 AC 339 ms
61,748 KB
testcase_16 AC 117 ms
39,716 KB
testcase_17 AC 541 ms
64,040 KB
testcase_18 AC 110 ms
37,284 KB
testcase_19 AC 449 ms
62,284 KB
testcase_20 AC 442 ms
62,300 KB
testcase_21 AC 498 ms
62,652 KB
testcase_22 AC 284 ms
54,948 KB
testcase_23 AC 551 ms
212,312 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();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var m = NN;
        var mod = 1_000_000_007;
        var dp = new long[m + 1][];
        dp[0] = new long[0];
        for (var i = 1; i < dp.Length; ++i)
        {
            dp[i] = new long[m / i + 1];
            dp[i][1] = 1;
        }
        for (var i = m; i > 0; --i)
        {
            var plist = PList(i);
            for (var j = 1; j < dp[i].Length; ++j)
            {
                foreach (var p in plist) if (i * j + p <= m)
                {
                    dp[p][i * j / p + 1] = (dp[p][i * j / p + 1] + dp[i][j]) % mod;
                }
            }
        }
        var ans = 0L;
        for (var i = 1; i <= m; ++i) if (m / i * i == m) ans = (ans + dp[i][m / i]) % mod;
        WriteLine(ans);
    }
    static List<int> PList(int n)
    {
        var ans = new List<int>();
        var rev = new List<int>();
        for (var i = 1; i * i <= n; ++i)
        {
            if (n % i == 0)
            {
                ans.Add(i);
                if (i * i < n) rev.Add(n / i);
            }
        }
        rev.Reverse();
        ans.AddRange(rev);
        return ans;
    }
}
0