結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-09 23:59:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 427 bytes |
| コンパイル時間 | 565 ms |
| コンパイル使用メモリ | 63,872 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-23 05:07:40 |
| 合計ジャッジ時間 | 1,537 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 WA * 6 |
ソースコード
#include <iostream>
using namespace std;
int main(){
string n,m;cin>>n>>m;
if(m == "0"){
cout << 0 << endl;
return 0;
}
int N = n[n.size()-1]-'0';
int M;
if(m.size() == 1){
M = m[0]-'0';
}else{
M = (m[m.size()-2]-'0')*10 + m[m.size()-1]-'0';
}
M %= 4;
int ans = N;
for(int i = 1; M > i; i++){
ans = (N*ans)%10;
}
cout << ans << endl;
}