結果

問題 No.403 2^2^2
ユーザー kappybarkappybar
提出日時 2020-05-13 16:23:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,059 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 168,592 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-12 17:00:22
合計ジャッジ時間 2,911 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

long long modpow(long long x, long long n,int MOD) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = (ret * x) % MOD;  
        x = (x * x) % MOD;
        n >>= 1;  
    }
    return ret;
}


int main(){
    string s;
    cin >> s;
    vector<ll> a;
    ll now = 0;
    ll c = 1;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i] < '0' || '9' < s[i]){
            a.push_back(now);
            now = 0;
            c = 1;
        }else{
            now = now + (s[i] - '0') * c;
            c *= 10;
        }
    }  
    a.push_back(now);
    reverse(a.begin(),a.end());

    ll ans1,ans2;
    ans1 = modpow( modpow(a[0]%MOD,a[1],MOD),a[2],MOD);
    ans2 = modpow(a[0]%MOD,modpow(a[1]%(MOD-1),a[2],MOD-1),MOD);
    cout << ans1 <<" " << ans2 << endl;
    return 0;
}
0