結果
問題 | No.403 2^2^2 |
ユーザー |
|
提出日時 | 2021-08-25 21:26:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 779 bytes |
コンパイル時間 | 2,098 ms |
コンパイル使用メモリ | 192,328 KB |
最終ジャッジ日時 | 2025-01-24 01:50:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#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; }