結果
| 問題 |
No.403 2^2^2
|
| ユーザー |
|
| 提出日時 | 2021-08-25 21:24:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 734 bytes |
| コンパイル時間 | 2,127 ms |
| コンパイル使用メモリ | 192,212 KB |
| 最終ジャッジ日時 | 2025-01-24 01:50:13 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 4 |
ソースコード
#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);
res2 = mypow(x,res2,MOD);
cout << res1 << ' ' << res2 << '\n';
return 0;
}