結果

問題 No.673 カブトムシ
ユーザー bluemeganebluemegane
提出日時 2021-05-08 13:08:06
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 977 bytes
コンパイル時間 1,844 ms
コンパイル使用メモリ 66,908 KB
実行使用メモリ 23,024 KB
最終ジャッジ日時 2023-10-14 23:41:33
合計ジャッジ時間 3,454 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 64 ms
20,804 KB
testcase_03 AC 60 ms
22,796 KB
testcase_04 AC 64 ms
20,812 KB
testcase_05 AC 66 ms
20,836 KB
testcase_06 AC 59 ms
23,008 KB
testcase_07 AC 64 ms
20,872 KB
testcase_08 AC 65 ms
20,764 KB
testcase_09 WA -
testcase_10 AC 64 ms
21,000 KB
testcase_11 AC 66 ms
20,892 KB
testcase_12 AC 64 ms
22,892 KB
testcase_13 AC 65 ms
20,952 KB
testcase_14 AC 65 ms
20,884 KB
testcase_15 AC 65 ms
22,872 KB
testcase_16 AC 66 ms
20,920 KB
testcase_17 AC 65 ms
20,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Numerics;
using System;

public class Hello
{
    public static int MOD = 1000000007;
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var b = long.Parse(line[0]);
        var c = long.Parse(line[1]);
        var d = long.Parse(line[2]);
        getAns(b, c, d);
    }
    static void getAns (long b, long c, long d)
    {
        if (c == 1)
        {
            var res0 = b % MOD;
            res0 *= d;
            res0 %= MOD;
            Console.WriteLine(res0);
            return;
        }
        BigInteger res = b % MOD;
        res *= c;
        res %= MOD;
        BigInteger t = BigInteger.ModPow(c, d, MOD) - 1;
        res *= t;
        res %= MOD;
        var t2 = ModInverse(c - 1, MOD);
        res *= t2;
        res %= MOD;
        Console.WriteLine(res);
    }
    public static BigInteger ModInverse(BigInteger a, BigInteger m)
    {
        return BigInteger.ModPow(a, m - 2, m);
    }
}
0