結果
問題 | No.167 N^M mod 10 |
ユーザー |
|
提出日時 | 2022-09-27 22:10:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 557 bytes |
コンパイル時間 | 1,931 ms |
コンパイル使用メモリ | 194,176 KB |
最終ジャッジ日時 | 2025-02-07 17:33:27 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#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;if(M == "0") {cout << 1 << endl;return 0;}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;}}