結果

問題 No.403 2^2^2
ユーザー snrnsidysnrnsidy
提出日時 2021-08-25 21:26:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 201,668 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 13:01:21
合計ジャッジ時間 3,104 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
 
using namespace std;

const long long int MOD = 1e9 + 7;
long long int mypow(long long int x,long long int n,long long int m)
{
	long long int res = 1;
	while(n > 0)
	{
		if(n%2==1)
		{
			res = ((res%m)*(x%m)%m);
			res%=m;
		}
		x = ((x%m)*(x%m)%m);
		x%=m;
		n/=2;
	}
	return res;
}

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

	string a;
	stringstream ss;

	long long int x,y,z;

	cin >> a;
	for(int i=0;i<a.length();i++)
	{
		if(a[i]=='^')
		{
			a[i] = ' ';
		}
	}

	ss << a;

	ss >> x >> y >> z;

	long long int res1 = mypow(x,y,MOD);
	res1 = mypow(res1,z,MOD);

	long long int res2 = mypow(y,z,MOD - 1);
	if(res2==0)
	{
		res2 = 0;
	}
	else
	{
		res2 = mypow(x,res2,MOD);
	}
	cout << res1 << ' ' << res2 << '\n';
	
	return 0;
}
0