結果

問題 No.167 N^M mod 10
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-10-24 07:54:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,658 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 145,092 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-15 18:32:17
合計ジャッジ時間 2,039 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(void){
	string n, m; cin >> n >> m;
	int num = n[n.size() - 1] - '0';
	if(m == "0"){
		printf("1\n");
		return 0;
	}

	int f = m[m.size() - 1] - '0';
	int ff;
	if("0" <= m && m <= "9"){
		ff = m[m.size() - 1] - '0';
	}else{
		ff = (m[m.size() - 2] - '0') * 10 + (m[m.size() - 1] - '0');
	}

	if(num == 0 || num == 1 || num == 5 || num == 6){
		printf("%d\n", num);
	}else if(num == 4){
		if(f % 2 == 0) printf("6\n");
		else printf("4\n");
	}else if(num == 9){
		if(f % 2 == 0) printf("1\n");
		else printf("9\n");
	}else if(num == 2){
		if(ff % 4 == 1) printf("2\n");
		else if(ff % 4 == 2) printf("4\n");
		else if(ff % 4 == 3) printf("8\n");
		else if(ff % 4 == 0) printf("6\n");
	}else if(num == 3){
		if(ff % 4 == 1) printf("3\n");
		else if(ff % 4 == 2) printf("9\n");
		else if(ff % 4 == 3) printf("7\n");
		else if(ff % 4 == 0) printf("1\n");
	}else if(num == 7){
		if(ff % 4 == 1) printf("7\n");
		else if(ff % 4 == 2) printf("9\n");
		else if(ff % 4 == 3) printf("3\n");
		else if(ff % 4 == 0) printf("1\n");
	}else if(num == 8){
		if(ff % 4 == 1) printf("8\n");
		else if(ff % 4 == 2) printf("4\n");
		else if(ff % 4 == 3) printf("2\n");
		else if(ff % 4 == 0) printf("6\n");
	}
	return 0;
}
0