about summary refs log tree commit diff
path: root/NTU/luth.c
blob: 0ef5dd4f25cde7b804427f7f1e420f8d27edc4f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>


short pow4(short x, long long n)
{
	if (n == 1)
		return x;

	long y = pow4(x, n / 2);
	y = y * y % 10000;

	if (n % 2)
		return y * x % 10000;
	else
		return y % 10000;
}


int main()
{
	short x;
	long long n;

	scanf("%hd %lld", &x, &n);

	printf("%hd\n", pow4(x, n));

	return 0;
}