結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-20 00:17:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 566 bytes |
| コンパイル時間 | 571 ms |
| コンパイル使用メモリ | 66,064 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-22 01:08:32 |
| 合計ジャッジ時間 | 1,461 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
using namespace std;
int main() {
string str_n, str_m;
cin >> str_n >> str_m;
int base = str_n[str_n.size() - 1] - '0';
if (str_m == "0") {
cout << 1 << endl;
return 0;
}
str_m = "0" + str_m;
int len = str_m.size();
int multiple = (str_m[len - 2] - '0') * 10 + str_m[len - 1] - '0';
multiple %= 4;
if (multiple == 0) { multiple = 4; }
int ans = (int) pow(base, multiple) % 10;
cout << ans << endl;
return 0;
}