結果

問題 No.251 大きな桁の復習問題(1)
ユーザー しらっ亭しらっ亭
提出日時 2016-07-08 14:28:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,510 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 166,160 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 01:05:52
合計ジャッジ時間 2,571 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
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 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

const long long mod = 129402307;

long long powMod(long long x, long long y) {
  long long r = 1, a = x % mod;
  while (y) {
    if (y & 1) r = (r * a) % mod;
    a = a * a % mod;
    y /= 2;
  }
  return r;
}

long long powModS(long long x, const string& y) {
  cout<<"x: "<<x<<endl;
  long long r = 1;
  x %= mod;
  for (char c : y) {
    int b = c - '0';
    r = powMod(r, 10);
    r = r * powMod(x, b);
    if (r > 100000000000000000LL) r %= mod;
  }
  return r % mod;
}

void Main() {
  string N, M;
  cin >> N >> M;

  long long n = 0;
  for (char c : N) {
    n = n * 10 + c - '0';
    if (n > 100000000000000000LL) n %= mod;
  }
  n %= mod;

  ll ans = powModS(n, M);
  cout << ans << endl;
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }
0