結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-27 22:06:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 487 bytes |
| コンパイル時間 | 2,026 ms |
| コンパイル使用メモリ | 195,264 KB |
| 最終ジャッジ日時 | 2025-02-07 17:33:02 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 WA * 2 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
string N,M; cin >> N >> M;
reverse(M.begin(), M.end());
while(M.size() > 2u) M.pop_back();
reverse(M.begin(), M.end());
int m4 = stoi(M) % 4;
int n10 = N.back() - '0';
if(n10 == 0) {
cout << 0 << endl;
} else {
cout << int(pow(n10, m4 + 4)) % 10 << endl;
}
}