結果

問題 No.673 カブトムシ
ユーザー bluemeganebluemegane
提出日時 2021-05-08 13:38:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 2,553 ms
コンパイル使用メモリ 67,152 KB
実行使用メモリ 22,820 KB
最終ジャッジ日時 2023-10-15 00:18:11
合計ジャッジ時間 4,652 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
20,792 KB
testcase_01 AC 65 ms
20,912 KB
testcase_02 AC 64 ms
20,900 KB
testcase_03 AC 63 ms
20,848 KB
testcase_04 AC 65 ms
20,816 KB
testcase_05 AC 65 ms
20,812 KB
testcase_06 AC 64 ms
20,864 KB
testcase_07 AC 64 ms
20,836 KB
testcase_08 AC 65 ms
22,800 KB
testcase_09 AC 65 ms
20,848 KB
testcase_10 AC 65 ms
20,748 KB
testcase_11 AC 64 ms
22,820 KB
testcase_12 AC 65 ms
22,804 KB
testcase_13 AC 64 ms
18,888 KB
testcase_14 AC 65 ms
20,960 KB
testcase_15 AC 66 ms
20,868 KB
testcase_16 AC 64 ms
18,788 KB
testcase_17 AC 65 ms
20,820 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)
    {
        b %= MOD;
        c %= MOD;
        if (c == 1)
        {
            BigInteger res0 = b % MOD;
            res0 *= d;
            res0 %= MOD;
            Console.WriteLine(res0);
            return;
        }
        if (d == 1)
        {
            BigInteger res0 = b % MOD;
            res0 *= c;
            res0 %= MOD;
            Console.WriteLine(res0);
            return;
        }
        BigInteger res = b * c;
        res %= MOD;
        var t = BigInteger.ModPow(c, d, MOD) - 1;
        res *= t;
        res %= MOD;
        res *= ModInverse(c - 1, MOD);
        res %= MOD;
        Console.WriteLine(res);
    }
    static BigInteger ModInverse(long a, long m) => BigInteger.ModPow(a, m - 2, m);
}
0