結果

問題 No.403 2^2^2
ユーザー nasadigitalnasadigital
提出日時 2016-07-23 19:57:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 1,321 ms
コンパイル使用メモリ 152,028 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 12:28:17
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007

using 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]);
        else
            rez.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;
}
0