結果

問題 No.403 2^2^2
ユーザー ei1333333
提出日時 2018-11-21 22:46:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 1,866 ms
コンパイル使用メモリ 193,032 KB
最終ジャッジ日時 2025-01-06 17:06:09
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |   scanf("%lld^%lld^%lld", &A, &B, &C);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

int64_t power(int64_t x, int64_t n, int64_t mod) {
  x %= mod;
  int64_t ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return (ret);
}

const int mod = 1e9 + 7;

int main() {
  int64 A, B, C;
  scanf("%lld^%lld^%lld", &A, &B, &C);
  cout << power(power(A, B, mod), C, mod) << " " << (A % mod == 0 ? 0 : power(A, power(B, C, mod - 1), mod)) << endl;
}

0