結果
問題 | No.167 N^M mod 10 |
ユーザー |
|
提出日時 | 2021-05-24 20:57:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 608 bytes |
コンパイル時間 | 1,754 ms |
コンパイル使用メモリ | 193,488 KB |
最終ジャッジ日時 | 2025-01-21 17:58:57 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long int;using ld = long double;#define pow(n,m) powl(n,m)#define sqrt(n) sqrtl(n)const ll MAX = 5000000000000000000;const ll MOD = 0;void randinit(){srand((unsigned)time(NULL));}int main(){string S,T;cin >> S >> T;if(T == "0"){cout << 1 << endl;return 0;}if(T.size() == 1) T = "0" + T;ll a = S[S.size() - 1] - '0',b = T[T.size() - 2] * 10 + T[T.size() - 1] - '0' * 11;ll ans = 1;b += 100;for(ll i = 0;i < b;i++){ans = (ans * a) % 10;}cout << ans << endl;}