結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2018-03-14 08:57:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 409 bytes |
| コンパイル時間 | 382 ms |
| コンパイル使用メモリ | 57,428 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-11-26 00:41:33 |
| 合計ジャッジ時間 | 1,197 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 WA * 1 |
ソースコード
#include<iostream>
#include<string>
using namespace std;
int main(){
string N,M;
int n,m,ans;
cin >> N >> M;
n = (int)N[N.length()-1]-48;
if(M.length() < 3) m = stoi(M);
else m = stoi(M.substr(M.length()-3));
if(M == "0") ans = 1;
else if(M == "1") ans = n;
else{
ans = n;
for(int i=1;i<m;i++) ans = ans*n%10;
}
cout << ans << endl;
return 0;
}
eve__fuyuki