結果

問題 No.167 N^M mod 10
ユーザー suppy193suppy193
提出日時 2017-02-02 16:11:23
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 567 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 25,648 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 18:06:03
合計ジャッジ時間 1,255 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int main(void) {
	int i, j;
	char n[10001], m[10001];
	int n2, m2;
	scanf("%s", n);
	scanf("%s", m);
	
	m2 = m[0] - '0';
	i = 1;
	while(m[i] != '\0'){
		m2 = m2 * 10 + m[i] - '0';
		m2 %= 4;
		i++;
	}
	//printf("%d\n", m2);
	if(i == 1 && m2 == 0){
		printf("1\n");
		return 0;
	}
	j = 0;
	while(n[j] != '\0'){
		j++;
	}
	n2 = n[j - 1] - '0';
	if(n2 == 1 || n2 == 5 || n2 == 6){
		printf("%d\n", n2);
		return 0;
	}
	
	//printf("%d^%d = %d\n", n2, m2, (int)pow(n2, m2) % 10);
	printf("%d\n", (int)pow(n2, m2) % 10);
	
	return 0;
}
0