結果

問題 No.673 カブトムシ
ユーザー bluemeganebluemegane
提出日時 2021-05-08 13:10:34
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 984 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 64,840 KB
実行使用メモリ 22,944 KB
最終ジャッジ日時 2023-10-14 23:45:00
合計ジャッジ時間 4,060 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 59 ms
22,840 KB
testcase_03 AC 57 ms
20,944 KB
testcase_04 AC 59 ms
20,916 KB
testcase_05 AC 60 ms
20,872 KB
testcase_06 AC 58 ms
20,968 KB
testcase_07 AC 59 ms
20,880 KB
testcase_08 AC 59 ms
20,836 KB
testcase_09 AC 59 ms
20,808 KB
testcase_10 AC 59 ms
20,880 KB
testcase_11 AC 60 ms
20,992 KB
testcase_12 AC 59 ms
20,824 KB
testcase_13 AC 60 ms
20,788 KB
testcase_14 AC 60 ms
20,968 KB
testcase_15 AC 61 ms
20,932 KB
testcase_16 AC 60 ms
22,944 KB
testcase_17 AC 60 ms
20,836 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)
        {
            BigInteger 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