結果

問題 No.403 2^2^2
ユーザー ふーらくたるふーらくたる
提出日時 2016-08-05 18:52:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 23,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 15:40:13
合計ジャッジ時間 919 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 0 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 0 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |     scanf("%lld^%lld^%lld", &A, &B, &C);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
using namespace std;

typedef long long ll;

const ll MOD = 1000 * 1000 * 1000 + 7;

ll pow_mod(ll a, ll n, ll mod) {
    if (n == 0) return 1;

    if (n % 2 == 0) {
        ll val = pow_mod(a, n / 2, mod);
        return (val * val) % mod;
    } else {
        return ((a % mod) * pow_mod(a, n - 1, mod)) % mod;
    }
}

int main() {
    ll A, B, C;
    scanf("%lld^%lld^%lld", &A, &B, &C);

    ll temp = pow_mod(A % MOD, B, MOD), ans1, ans2;
    ans1 = pow_mod(temp, C, MOD);

    if (A % MOD == 0) {
        ans2 = 0;
    } else {
        temp = pow_mod(B % MOD - 1, C, MOD - 1);
        ans2 = pow_mod(A % MOD, temp, MOD);
    }

    printf("%lld %lld\n", ans1, ans2);

    return 0;
}
0