結果

問題 No.403 2^2^2
ユーザー ゆにぽけゆにぽけ
提出日時 2023-10-21 04:32:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 1,258 ms
コンパイル使用メモリ 126,928 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 04:32:23
合計ジャッジ時間 2,309 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
using namespace std;
const int mod = (int)1e9+7;
string S;
long long f(long long P,long long N,int M)
{
	long long res = 1;
	P %= M;
	while(N)
	{
		if(N & 1) res = res*P%M;
		P = P*P%M;
		N >>= 1;
	}
	return res;
}
void solve()
{
	cin >> S;
	int l = -1,r = -1;
	for(int i = 0;i < (int)S.size();i++) if(S[i] == '^')
	{
		if(l < 0) l = i;
		else r = i;
	}
	long long A = stoll(S.substr(0,l)),B = stoll(S.substr(l+1,r-l-1)),C = stoll(S.substr(r+1));
	cout << f(f(A,B,mod),C,mod) << " " << f(A,f(B,C,mod-1),mod) << endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	//cin >> tt;
	while(tt--) solve();
}
0