結果

問題 No.1578 A × B × C
ユーザー rtyu
提出日時 2021-07-08 09:04:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 1,150 ms
コンパイル使用メモリ 69,036 KB
最終ジャッジ日時 2025-01-22 18:06:06
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

long long md = 1000000007;

long long fp(long long n, long long k, long long m)
{
    long long s = 1;
    while (k) {
        if (k & 1LL) s = (s * n) % m;
        n = (n * n) % m; k /= 2;
    }
    return s;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a, b, c, k; cin >> a >> b >> c >> k;
    a = (a * b) % md; a = (a * c) % md;
    cout << fp(a, fp(2, k, md - 1), md) << '\n';
    return 0;
}
0