結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-15 18:28:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 499 bytes |
| コンパイル時間 | 1,921 ms |
| コンパイル使用メモリ | 195,028 KB |
| 最終ジャッジ日時 | 2025-01-15 07:35:34 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
string s,t; cin >> s >> t;
if(t=="0")printf("1\n");
else{
int p=s.back()-'0';
int q;
if(t.size()==1)q=t.back()-'0';
else q=(t[t.size()-2]-'0')*10+t.back()-'0';
q%=4;
if(q==0)q=4;
int res=p;
for(int i=0;i<q-1;i++){
res*=p;
}
cout << res%10 << endl;
}
}