結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2020-11-10 12:34:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 354 bytes |
コンパイル時間 | 737 ms |
コンパイル使用メモリ | 66,328 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-22 17:25:56 |
合計ジャッジ時間 | 1,883 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <iostream>#include <string>using namespace std;int main(){string N;cin >> N;string M;cin >> M;if (M == "0"){cout << 1 << endl;return 0;}M = "0" + M;int a = stoi(N.substr(N.size() - 1));int b = stoi(M.substr(M.size() - 2)) % 4 + 4;int ans = 1;for (int i = 0; i < b; i++){ans *= a;}cout << ans % 10 << endl;}