結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
eri
|
| 提出日時 | 2015-07-15 01:57:38 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 422 bytes |
| 記録 | |
| コンパイル時間 | 331 ms |
| コンパイル使用メモリ | 71,800 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-10 06:41:42 |
| 合計ジャッジ時間 | 1,326 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#include<iostream>
#include<string>
using namespace std;
int main(void){
string n, m; cin >> n >> m;
if (m == "0"){ cout << 1 << endl; return 0; }
int x = n[n.length() - 1] - '0';
int y = m[m.length() - 1] - '0';
if (m.length() >= 2){ y += 10 * (m[m.length() - 2] - '0'); }
if (m.length() >= 3){ y += 100; }
int ans = 1;
for (int i = 0; i < y; i++){
ans *= x;
ans %= 10;
}
cout << ans << endl;
return 0;
}
eri