結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-14 04:13:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 1,000 ms |
| コード長 | 713 bytes |
| コンパイル時間 | 6,448 ms |
| コンパイル使用メモリ | 381,292 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-18 07:52:58 |
| 合計ジャッジ時間 | 7,650 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#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;
}