結果

問題 No.2176 LRM Question 1
ユーザー 👑 kakel-sankakel-san
提出日時 2023-09-04 20:50:25
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 68,020 KB
実行使用メモリ 38,824 KB
最終ジャッジ日時 2023-09-04 20:50:31
合計ジャッジ時間 4,175 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
23,868 KB
testcase_01 AC 62 ms
23,856 KB
testcase_02 AC 106 ms
36,836 KB
testcase_03 AC 62 ms
21,820 KB
testcase_04 AC 94 ms
36,816 KB
testcase_05 AC 63 ms
19,928 KB
testcase_06 AC 60 ms
23,832 KB
testcase_07 AC 62 ms
21,912 KB
testcase_08 AC 90 ms
38,824 KB
testcase_09 AC 89 ms
36,408 KB
testcase_10 AC 98 ms
34,412 KB
testcase_11 AC 59 ms
21,784 KB
testcase_12 AC 60 ms
23,836 KB
testcase_13 AC 93 ms
36,836 KB
testcase_14 AC 105 ms
36,864 KB
testcase_15 AC 97 ms
35,580 KB
testcase_16 AC 90 ms
33,284 KB
testcase_17 AC 60 ms
21,756 KB
testcase_18 AC 87 ms
35,332 KB
testcase_19 AC 79 ms
32,820 KB
testcase_20 AC 67 ms
24,404 KB
testcase_21 AC 80 ms
27,460 KB
testcase_22 AC 63 ms
21,692 KB
testcase_23 AC 79 ms
26,672 KB
testcase_24 AC 79 ms
27,788 KB
権限があれば一括ダウンロードができます

ソースコード

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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (l, r, m) = (c[0], c[1], c[2]);
        if (m == 1)
        {
            WriteLine(0);
            return;
        }
        var f = new long[m];
        f[1] = 1;
        var dp = new long[m];
        dp[1] = 1;
        for (var i = 2; i < m; ++i)
        {
            f[i] = f[i - 1] * i % m;
            dp[i] = dp[i - 1] * f[i] % m;
        }
        var ans = 0L;
        for (var i = l; i <= r && i < m; ++i) ans = (ans + dp[i]) % m;
        WriteLine(ans);
    }
}
0