結果
| 問題 | No.673 カブトムシ | 
| コンテスト | |
| ユーザー |  bluemegane | 
| 提出日時 | 2021-05-08 13:38:47 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 30 ms / 2,000 ms | 
| コード長 | 1,112 bytes | 
| コンパイル時間 | 1,985 ms | 
| コンパイル使用メモリ | 104,064 KB | 
| 実行使用メモリ | 18,688 KB | 
| 最終ジャッジ日時 | 2024-09-16 17:50:46 | 
| 合計ジャッジ時間 | 3,462 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 14 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
            
            
            
        