結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
ry0u_yd
|
| 提出日時 | 2015-09-05 04:24:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 765 bytes |
| コンパイル時間 | 573 ms |
| コンパイル使用メモリ | 73,048 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-22 01:21:43 |
| 合計ジャッジ時間 | 1,478 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main() {
string s,t;
cin >> s >> t;
int a = s[s.size()-1] - '0';
stringstream ss;
if(t.size() == 1) {
ss << t[0];
} else {
ss << t[t.size()-2];
ss << t[t.size()-1];
}
int tmp;
ss >> tmp;
int b = tmp % 4;
if(b == 0 && t != "0") b = 4;
int res = pow(a,b);
res %= 10;
cout << res << endl;
return 0;
}
ry0u_yd