結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
|
| 提出日時 | 2018-05-12 20:29:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 365 bytes |
| コンパイル時間 | 529 ms |
| コンパイル使用メモリ | 65,508 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-28 09:42:27 |
| 合計ジャッジ時間 | 1,729 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 WA * 8 |
ソースコード
#include<iostream>
using namespace std;
int main(){
string ns, ms;
int n, m;
cin >> ns >> ms;
n = ns[ns.size()-1]-'0';
if(ms.size() == 1){
m = stoi(ms);
}else{
m = stoi(ms.substr(ms.size()-2,2));
}
m %= 4;
int a = 1;
for(int i = 0; i < m; i++){
a *= n;
}
cout << a%10 << endl;
return 0;
}