結果

問題 No.673 カブトムシ
ユーザー ミドリムシミドリムシ
提出日時 2018-04-13 22:44:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 73,092 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-09 04:42:23
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,504 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;

#define YES(condition) if(condition){ cout << "YES" << endl; }else{ cout << "NO" << endl; }
#define Yes(condition) if(condition){ cout << "Yes" << endl; }else{ cout << "No" << endl; }
#define Poss(condition) if(condition){ cout << "Possible" << endl; }else{ cout << "Impossible" << endl; }

#define mod long(1e9 + 7)

long power(long base, long exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}

int main(){
    long B, C, D;
    cin >> B >> C >> D;
    B %= mod;
    C %= mod;
    D %= mod;
    if(C == 1){
        cout << B * D % mod << endl;
        return 0;
    }
    cout << B * (power(C, D + 1) - C + mod) % mod * power((C + mod - 1) % mod, mod - 2) % mod << endl;
}
0