結果
問題 | No.403 2^2^2 |
ユーザー |
![]() |
提出日時 | 2016-07-22 23:16:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,791 bytes |
コンパイル時間 | 1,021 ms |
コンパイル使用メモリ | 101,684 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-06 15:16:49 |
合計ジャッジ時間 | 1,840 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>//#include<cctype>#include<climits>#include<iostream>#include<string>#include<vector>#include<map>//#include<list>#include<queue>#include<deque>#include<algorithm>//#include<numeric>#include<utility>//#include<memory>#include<functional>#include<cassert>#include<set>#include<stack>#include<random>const int dx[] = {1, 0, -1, 0};const int dy[] = {0, -1, 0, 1};using namespace std;typedef long long ll;typedef unsigned long long ull;typedef vector<int> vi;typedef vector<ll> vll;typedef pair<int, int> pii;ll mod_pow(ll x, ll p, ll MOD) {if (x == 0) return 0;ll a = 1;while (p) {if (p%2) a = a*x%MOD;x = x*x%MOD;p/=2;}return a;}pair<pair<ll, ll>, ll> unko(string s) {int n = s.size();pair<pair<ll, ll>, ll> ret;int div = 0;for (int i = 0; i < n; i++) {if (s[i] == '^') {if (ret.first.first == 0) {ret.first.first = stoll(s.substr(0, i));div = i+1;} else {ret.first.second = stoll(s.substr(div, i-div));ret.second = stoll(s.substr(i+1));}}}return ret;}const ll MOD = 1e9+7;ll solve1(ll A, ll B, ll C) {ll tmp = mod_pow(A%MOD, B, MOD);return mod_pow(tmp, C, MOD);}ll solve2(ll A, ll B, ll C) {ll tmp = mod_pow(B%(MOD-1), C, MOD-1);return mod_pow(A%MOD, tmp, MOD);}int main() {cin.tie(0);ios::sync_with_stdio(false);ll A, B, C;{string s;cin >> s;auto p = unko(s);A = p.first.first, B = p.first.second, C = p.second;}cout << solve1(A, B, C) << " " << solve2(A, B, C) << endl;return 0;}