結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-15 18:28:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 499 bytes |
| コンパイル時間 | 1,875 ms |
| コンパイル使用メモリ | 194,516 KB |
| 最終ジャッジ日時 | 2025-01-15 07:35:25 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 WA * 2 |
ソースコード
#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("0\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;
}
}