結果

問題 No.403 2^2^2
ユーザー 👑 obakyanobakyan
提出日時 2019-05-02 11:52:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 71,232 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 04:43:27
合計ジャッジ時間 1,930 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#define L64 long long
#define MOD (1000000007LL)

L64 modpow(L64 src, L64 pow, L64 mod)
{
  L64 res = 1;
  while (0 < pow) {
    if (pow % 2 == 1) {
      res = (res * src) % mod;
      pow--;
    }
    src = (src * src) % mod;
    pow /= 2;
  }
  return res;
}

L64 modinv(L64 src, L64 mod)
{
  return modpow(src, mod - 2, mod);
}

int main(void)
{
  L64 a, b, c;
  scanf("%lld^%lld^%lld", &a, &b, &c);
  L64 r1 = modpow(a % MOD, b, MOD);
  r1 = modpow(r1, c, MOD);
  L64 r2 = modpow(b % (MOD - 1LL), c, MOD - 1LL);
  if(r2 == 0LL){
    r2 = MOD - 1LL;
  }
    r2 = modpow(a % MOD, r2, MOD);
  std::cout << r1 << " " << r2 << std::endl;
}
0