結果
問題 | No.403 2^2^2 |
ユーザー |
![]() |
提出日時 | 2016-07-23 19:57:49 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,150 bytes |
コンパイル時間 | 1,508 ms |
コンパイル使用メモリ | 166,120 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-06 15:36:29 |
合計ジャッジ時間 | 2,469 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>#define MOD 1000000007using namespace std;typedef long long ll;typedef pair<int,int> ii;vector<string> split(string a,char e){vector<string> rez;string cur;for(int ctr1=0;ctr1<a.size();ctr1++){if(a[ctr1]!=e)cur.push_back(a[ctr1]);elserez.push_back(cur),cur.clear();}if(cur!="")rez.push_back(cur);return rez;}ll stroi(string a){ll rez=0;for(int ctr1=0;ctr1<a.size();ctr1++)rez*=10,rez+=a[ctr1]-'0';return rez;}ll ipow(ll base, ll exp, ll mod){ll result = 1;while (exp){if (exp & 1)result = (result*base)%mod;exp >>= 1;base = (base*base)%mod;}return result;}int main(){string s;cin>>s;vector<string> r=split(s,'^');vector<ll> no;for(int ctr1=0;ctr1<3;ctr1++)no.push_back(stroi(r[ctr1]));no[0]%=MOD;if(no[0]==0){cout<<0<<" "<<0;return 0;}cout<< ipow(ipow(no[0],no[1],MOD),no[2],MOD) << " " << ipow(no[0], ipow(no[1]%(MOD-1),no[2],MOD-1),MOD) <<"\n";return 0;}