結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
cureskol
|
| 提出日時 | 2020-04-10 05:02:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 371 bytes |
| コンパイル時間 | 1,593 ms |
| コンパイル使用メモリ | 166,652 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-14 09:22:57 |
| 合計ジャッジ時間 | 2,654 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 WA * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int MOD=10;
int pw(int n,int k){
assert(k>=0);
int res=1;
while(k){
if(k&1)(res*=n)%=MOD;
(n*=n)%=MOD;
k>>=1;
}
return res;
}
signed main(){
string n,m;cin>>n>>m;
int N=(int)(n.back()-'0'),M;
M=(int)(n.back()-'0');
if(n.size()>=2)M+=(int)(n[n.size()-2]-'0')*10;
cout<<pw(N,M)<<endl;
}
cureskol