結果

問題 No.167 N^M mod 10
ユーザー 競ピー競ピー
提出日時 2023-03-14 04:13:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 1,000 ms
コード長 713 bytes
コンパイル時間 12,766 ms
コンパイル使用メモリ 388,208 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 11:28:20
合計ジャッジ時間 15,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);i++)//0-indexed
#define REP(i,j,n) for(int i=j;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define INF 1e9
namespace mp = boost::multiprecision;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

//power
mp::cpp_int mypower(mp::cpp_int a,mp::cpp_int b,mp::cpp_int m){
    mp::cpp_int res=1,x=a;
    while(b){
        if(b&1){
            res=(res*x)%m;
        }
        x=(x*x)%m;
        b>>=1;
    }
    return res;
}

int main(){
    mp::cpp_int n,m;
    cin>>n>>m;
    cout<<mypower(n,m,10)<<endl;

}
0