結果

問題 No.403 2^2^2
ユーザー snrnsidysnrnsidy
提出日時 2021-08-25 21:25:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 1,799 ms
コンパイル使用メモリ 201,488 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 13:00:13
合計ジャッジ時間 2,861 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
6,944 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 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);
	res2 = mypow(x,res2,MOD);

	cout << res1 << ' ' << res2 << '\n';
	
	return 0;
}
0