結果

問題 No.251 大きな桁の復習問題(1)
ユーザー legosukelegosuke
提出日時 2018-03-10 05:52:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 1,257 ms
コンパイル使用メモリ 145,188 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-02 01:46:42
合計ジャッジ時間 2,796 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll mod = 129402307;
string N, M;

ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  ll n = 0;
  for (int i = 0; i < N.size(); i++) {
    n = (n * 10 + N[i] - '0') % mod;
  }
  ll m = 0;
  for (int i = 0; i < M.size(); i++) {
    m = (m * 10 + M[i] - '0') % (mod - 1);
  }
  cout << (n == 0 ? 0 : mod_pow(n, m, mod)) << endl;

  return 0;
}
0