結果

問題 No.403 2^2^2
ユーザー outline
提出日時 2021-02-08 21:10:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,721 bytes
コンパイル時間 3,361 ms
コンパイル使用メモリ 129,500 KB
最終ジャッジ日時 2025-01-18 16:28:10
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;
template<class T>
inline bool chmax(T& x, T y){
if(x < y){
x = y;
return true;
}
return false;
}
template<class T>
inline bool chmin(T& x, T y){
if(x > y){
x = y;
return true;
}
return false;
}
ll modpow(ll x, ll n, ll m){
if(x == 0 && n == 0) return 0LL;
ll res = 1LL;
while(n > 0){
if(n & 1) (res *= x) %= m;
(x *= x) %= m;
n >>= 1;
}
return res;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
int n = s.length(), j = -1;
ll A = -1, B = -1, C = -1;
for(int i = 0; i < n; ++i){
if(s[i] != '^') continue;
if(A == -1){
A = stoll(s.substr(0, i)) % mod;
j = i;
}
else if(B == -1){
B = stoll(s.substr(j + 1, i - (j + 1)));
C = stoll(s.substr(i + 1, n - (i + 1)));
}
}
cout << modpow(modpow(A, B, mod), C, mod) << ' ';
cout << modpow(A, modpow(B % (mod - 1), C, mod - 1), mod) << '\n';
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0