結果

問題 No.673 カブトムシ
ユーザー llllll
提出日時 2018-04-13 23:47:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 90,316 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 18:12:02
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

const ll mod = 1000000007;

ll powmod(ll a, ll b) {
    ll ret = 1;
    while (b) {
        if (b % 2 == 1) {
            ret = (ret * a) % mod;
        }
        a = (a * a) % mod;
        b /= 2;
    }
    return ret;
}

ll sum(ll a, ll r, ll n) {
    if (n == 1) {
        return a % mod;
    }

    ll x = sum(a, r, n / 2);
    ll ret = (x + powmod(r, n / 2) * x) % mod;
    if (n % 2 == 1) {
        ret = (a + r * ret) % mod;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll B, C, D;
    cin >> B >> C >> D;

    B %= mod;
    C %= mod;
    cout << (B * sum(C, C, D)) % mod << endl;

    return 0;
}
0