結果

問題 No.1161 Many Powers
ユーザー bluemeganebluemegane
提出日時 2021-05-19 17:02:30
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 103,680 KB
実行使用メモリ 21,912 KB
最終ジャッジ日時 2024-04-18 03:05:29
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
17,920 KB
testcase_01 AC 27 ms
18,048 KB
testcase_02 AC 25 ms
18,048 KB
testcase_03 AC 28 ms
18,048 KB
testcase_04 AC 26 ms
18,048 KB
testcase_05 AC 30 ms
18,176 KB
testcase_06 AC 29 ms
18,048 KB
testcase_07 AC 26 ms
18,048 KB
testcase_08 AC 56 ms
19,708 KB
testcase_09 AC 60 ms
19,884 KB
testcase_10 AC 39 ms
18,668 KB
testcase_11 AC 50 ms
19,288 KB
testcase_12 AC 37 ms
18,688 KB
testcase_13 AC 65 ms
19,792 KB
testcase_14 AC 87 ms
21,024 KB
testcase_15 AC 77 ms
20,396 KB
testcase_16 AC 93 ms
21,552 KB
testcase_17 AC 69 ms
20,512 KB
testcase_18 AC 58 ms
19,740 KB
testcase_19 AC 45 ms
19,044 KB
testcase_20 AC 97 ms
21,888 KB
testcase_21 AC 44 ms
18,940 KB
testcase_22 AC 99 ms
21,912 KB
testcase_23 AC 27 ms
18,048 KB
testcase_24 AC 27 ms
18,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Numerics;
using System;

public class Hello
{
    public static int MOD;
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(line[0]);
        var b = long.Parse(line[1]);
        MOD = int.Parse(line[2]);
        getAns(a, b);
    }
    static void getAns(long a, long b)
    {
        var t = new long[MOD];
        var tv = a / MOD;
        for (int i = 0; i < MOD; i++) t[i] = tv;
        var y = a - tv * MOD;
        for (int i = 1; i <= y; i++) t[i]++;
        var ans = 0L;
        for (int i = 1; i < MOD; i++)
        {
            ans += t[i] * (long)BigInteger.ModPow(i, b, MOD);
            ans %= MOD;
        }
        Console.WriteLine(ans);
    }
}
0