結果
問題 | No.167 N^M mod 10 |
ユーザー |
|
提出日時 | 2019-08-08 01:14:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 471 bytes |
コンパイル時間 | 1,808 ms |
コンパイル使用メモリ | 194,624 KB |
最終ジャッジ日時 | 2025-01-07 10:59:48 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;int f(char c) {if ('0' <= c && c <= '9') return c-'0';return c-'A'+10;}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;}