結果

問題 No.403 2^2^2
ユーザー 👑 obakyan
提出日時 2019-05-02 11:49:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 73,008 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-31 13:18:00
合計ジャッジ時間 1,759 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |   scanf("%lld^%lld^%lld", &a, &b, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

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);
  r2 = modpow(a % MOD, r2, MOD);
  std::cout << r1 << " " << r2 << std::endl;
}
0