結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-06-14 02:50:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 554 bytes |
| コンパイル時間 | 591 ms |
| コンパイル使用メモリ | 74,856 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-22 01:17:09 |
| 合計ジャッジ時間 | 1,524 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;
typedef long long LL;
int main(){
string ns, ms;
cin >> ns >> ms;
LL N = ns[ns.size()-1] - '0';
LL M = ms[ms.size()-1] - '0';
if(ms.size() >= 2) M += 10 * (ms[ms.size()-2]-'0');
LL ans = 1;
if(N == 0 && (ms.size() > 1 || M != 0)) ans = 0;
if(ms.size() > 2) M += 100;
for(int i = 0; i < M; i++){
ans = ans*N % 10;
}
cout << ans << endl;
return 0;
}
machy