結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
|
| 提出日時 | 2019-08-08 01:15:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 387 bytes |
| コンパイル時間 | 2,248 ms |
| コンパイル使用メモリ | 193,804 KB |
| 最終ジャッジ日時 | 2025-01-07 10:59:57 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
string n,m;
cin>>n>>m;
int a=n[n.size()-1]-'0';
int b;
if (m.size()>=2) b=stoi(m.substr(m.size()-2));
else {
b=m[m.size()-1]-'0';
if (b==0) {
puts("1");
return 0;
}
}
b=b%4+4;
cout<<(int)pow(a,b)%10<<endl;
return 0;
}