結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-02-16 11:02:47 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 416 bytes |
| 記録 | |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 72,556 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-10 06:52:27 |
| 合計ジャッジ時間 | 1,541 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
int main() {
string nstr, mstr;
cin >> nstr >> mstr;
int n = atoi(&nstr.back());
int m = (mstr.length() > 2) ? stoi(mstr.substr(mstr.size()-2,2)) : stoi(mstr);
m = (mstr.length() == 1 && m == 0) ? 0 : (m+3) % 4 + 1;
int ans = 1;
for (int i = 0; i < m; i++)
ans = (ans * n) % 10;
cout << ans << endl;
return 0;
}
h_noson