結果

問題 No.403 2^2^2
ユーザー femtofemto
提出日時 2016-07-23 00:35:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 915 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 68,840 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 05:27:48
合計ジャッジ時間 1,726 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,948 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
6,940 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
6,940 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 WA -
testcase_29 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

const int mod = 1000000007;

ll modpow(ll x, ll y, ll m) {
	if(y == 0) return 1;
	ll res = modpow(x, y / 2, m);
	return res * res % m * (y & 1 ? x : 1) % m;
}

ll modinv(ll x, ll m) {
	return modpow(x, m - 2, m);
}


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

	ll A, B, C;
	string s;
	cin >> s;

	int idx = s.find('^');
	A = atoll(s.substr(0, idx).c_str());
	s = s.substr(idx + 1, s.size() - idx - 1);
	idx = s.find('^');
	B = atoll(s.substr(0, idx).c_str());
	s = s.substr(idx + 1, s.size() - idx - 1);
	C = atoll(s.c_str());

	A %= mod, B %= mod, C %= mod;

	ll Ab = modpow(A, B, mod);
	ll Bc = modpow(B, C, mod - 1);

	ll ans1 = modpow(Ab, C, mod);
	ll ans2 = modpow(A, Bc, mod);

	cout << ans1 << " " << ans2 << endl;
}
0