結果

問題 No.1973 Divisor Sequence
ユーザー 👑 kakel-sankakel-san
提出日時 2022-06-10 22:39:12
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,707 bytes
コンパイル時間 2,579 ms
コンパイル使用メモリ 109,788 KB
実行使用メモリ 33,448 KB
最終ジャッジ日時 2023-10-21 05:29:43
合計ジャッジ時間 11,237 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
25,720 KB
testcase_01 AC 36 ms
25,720 KB
testcase_02 AC 873 ms
29,828 KB
testcase_03 AC 50 ms
27,780 KB
testcase_04 AC 528 ms
29,828 KB
testcase_05 AC 63 ms
29,816 KB
testcase_06 AC 255 ms
29,828 KB
testcase_07 AC 81 ms
29,828 KB
testcase_08 AC 161 ms
29,828 KB
testcase_09 AC 467 ms
29,828 KB
testcase_10 AC 1,125 ms
29,828 KB
testcase_11 AC 110 ms
29,828 KB
testcase_12 AC 221 ms
29,828 KB
testcase_13 AC 139 ms
29,828 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, m) = ((int)c[0], c[1]);
        WriteLine(Divisor(n, m));
    }
    static long Divisor(int n, long m)
    {
        var plist = PDiv(m);
        var dic = new Dictionary<long, int>();
        for (var i = 0; i < plist.Count; ++i) dic.Add(plist[i], i);

        var moves = new bool[plist.Count][];
        for (var i = 0; i < moves.Length; ++i)
        {
            moves[i] = new bool[plist.Count];
            for (var j = 0; j < moves[i].Length; ++j)
            {
                if (m % ((decimal)plist[i] * plist[j]) == 0) moves[i][j] = true;
            }
        }
        var dp = Enumerable.Repeat(1L, plist.Count).ToArray();
        var mod = 1_000_000_007;
        for (var i = 1; i < n; ++i)
        {
            var next = new long[plist.Count];
            for (var p = 0; p < dp.Length; ++p) for (var v = 0; v < next.Length; ++v) if (moves[p][v])
            {
                next[v] = (next[v] + dp[p]) % mod;
            }
            dp = next;
        }
        return (dp.Sum() % mod);
    }
    static List<long> PDiv(long x)
    {
        var list = new List<long>();
        var rev = new List<long>();
        for (var i = 1L; i * i <= x; ++i) if (x % i == 0)
        {
            list.Add(i);
            if (i * i < x) rev.Add(x / i);
        }
        rev.Reverse();
        return list.Concat(rev).ToList();
    }
}
0