結果

問題 No.167 N^M mod 10
ユーザー ty70ty70
提出日時 2015-05-15 11:38:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,029 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 85,372 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 08:05:05
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int ans[10][10] = {
		//0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (=m)
		{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },	// n = 0
		{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },	// n = 1
		{ 6, 2, 4, 8, 6, 2, 4, 8, 6, 2 },	// n = 2
		{ 1, 3, 9, 7, 1, 3, 9, 7, 1, 3 },	// n = 3
		{ 6, 4, 6, 4, 6, 4, 6, 4, 6, 4 },	// n = 4
		{ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },	// n = 5
		{ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },	// n = 6
		{ 1, 7, 9, 3, 1, 7, 9, 3, 1, 7 },	// n = 7
		{ 6, 8, 4, 2, 6, 8, 4, 2, 6, 8 },	// n = 8
		{ 1, 9, 1, 9, 1, 9, 1, 9, 1, 9 }	// n = 9
};

int main()
{
	ios_base::sync_with_stdio(0);
	string N, M; cin >> N >> M;
	
	int n = (int)(N[N.length()-1] - '0' );
	int m = (int)(M[M.length()-1] - '0' );
	if (M.length() >= 2 ){
		m += (int)(M[M.length()-2] - '0' )*10;
	} // end if

	int res = 0;
	if (m == 0 ){
		res = 1;
	}else{
		res = ans[n][m%4];
	} // end if
	cout << res << endl;  

	return 0;
}
0