結果

問題 No.673 カブトムシ
ユーザー bluemeganebluemegane
提出日時 2021-05-08 13:25:36
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,215 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 62,808 KB
実行使用メモリ 24,952 KB
最終ジャッジ日時 2023-10-15 00:01:16
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
20,916 KB
testcase_01 AC 61 ms
20,928 KB
testcase_02 AC 62 ms
22,984 KB
testcase_03 AC 61 ms
20,940 KB
testcase_04 AC 63 ms
24,952 KB
testcase_05 WA -
testcase_06 AC 61 ms
20,808 KB
testcase_07 AC 62 ms
20,884 KB
testcase_08 AC 63 ms
20,860 KB
testcase_09 AC 62 ms
20,840 KB
testcase_10 AC 63 ms
20,908 KB
testcase_11 AC 63 ms
20,948 KB
testcase_12 WA -
testcase_13 AC 64 ms
20,856 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
        d %= 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;
        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