結果

問題 No.251 大きな桁の復習問題(1)
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-04 16:52:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 617 bytes
コンパイル時間 13,482 ms
コンパイル使用メモリ 434,184 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-09-30 18:30:45
合計ジャッジ時間 12,719 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/251/
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;

const ll mod = 129402307;

int main() {
    cpp_int N, M;
    cin >> N >> M;
    if (M == 0) {
        cout << 1 << endl;
        return 0;
    }
    N %= mod;
    M %= (mod - 1);
    cpp_int ans = 1;
    if (N == 0 && M == 0)
        ans = 0;
    while (M) {
        if (M % 2 == 1) {
            ans *= N;
            ans %= mod;
        }
        N *= N;
        N %= mod;
        M /= 2;
    }
    cout << ans << endl;
}
0