結果

問題 No.2394 部分和乗総和
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-28 21:59:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 110,836 KB
実行使用メモリ 43,848 KB
最終ジャッジ日時 2024-04-16 05:54:00
合計ジャッジ時間 4,486 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
27,000 KB
testcase_01 AC 29 ms
26,876 KB
testcase_02 AC 29 ms
24,832 KB
testcase_03 AC 29 ms
25,116 KB
testcase_04 AC 29 ms
27,024 KB
testcase_05 AC 28 ms
22,968 KB
testcase_06 AC 29 ms
24,884 KB
testcase_07 AC 29 ms
25,080 KB
testcase_08 AC 29 ms
24,988 KB
testcase_09 AC 29 ms
24,856 KB
testcase_10 AC 29 ms
24,988 KB
testcase_11 AC 28 ms
24,856 KB
testcase_12 AC 29 ms
26,896 KB
testcase_13 AC 64 ms
26,652 KB
testcase_14 AC 147 ms
32,188 KB
testcase_15 AC 155 ms
32,380 KB
testcase_16 AC 209 ms
32,164 KB
testcase_17 AC 366 ms
43,412 KB
testcase_18 AC 366 ms
43,276 KB
testcase_19 AC 365 ms
41,364 KB
testcase_20 AC 364 ms
43,848 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
{
    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 (n, m, b) = (c[0], c[1], (int)c[2]);
        var a = NList;
        var ans = 1L;
        foreach (var ai in a)
        {
            ans = ans * (1 + Exp(m, ai, b)) % b;
        }
        WriteLine(ans);
    }
    static long Exp(long n, long k, int mod)
    {
        n = n % mod;
        if (k == 0) return 1;
        if (k == 1) return n % mod;
        var half = Exp(n, k / 2, mod);
        var result = (half * half) % mod;
        return ((k % 2) == 0) ? result : ((result * n) % mod);
    }
}
0