結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
hayaD
|
| 提出日時 | 2016-08-14 09:57:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 747 bytes |
| コンパイル時間 | 864 ms |
| コンパイル使用メモリ | 82,636 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-07 16:41:09 |
| 合計ジャッジ時間 | 1,578 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 WA * 2 |
ソースコード
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
int main(){
string N;
string M;
cin >> N >> M;
string N2 = N.substr(N.length()-1,1);
int Nd = atoi(N2.c_str());
int Md;
if (M.length() == 1){
Md = atoi(M.c_str());
}else{
string M2 = M.substr(M.length()-2,2);
Md = atoi(M2.c_str());
}
int ans = 1;
if(Md == 0) Md += 4;
FOR(i,0,Md){
ans = (ans * Nd)%10;
}
cout << ans << endl;
return 0;
}
hayaD