結果

問題 No.403 2^2^2
ユーザー fine
提出日時 2017-03-14 01:37:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 165,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-30 00:41:15
合計ジャッジ時間 2,702 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll modpow(ll x, ll n, ll mod) {
	if (x == 0) return 0;
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c;
	scanf("%lld^%lld^%lld", &a, &b, &c);
	cout << modpow(modpow(a % MOD, b, MOD), c, MOD);
	cout  << " ";
	cout << modpow(a % MOD, modpow(b % (MOD - 1), c, MOD - 1), MOD) << endl;
	return 0;
}
0