Created
March 5, 2015 18:47
-
-
Save henrybear327/4cee24baa0719b4b738a to your computer and use it in GitHub Desktop.
w2c(new with help from stack overflow).c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int test_cases; | |
while(scanf("%d", &test_cases) != EOF) { | |
while(test_cases--) { | |
int x, y, N; | |
scanf("%d %d %d", &x, &y, &N); | |
if(x <= 0 || y <= 0 || N <= 0 || N > 10000) | |
break; | |
int a1 = x % N; | |
int p = 1; | |
int i; | |
for(i = 1; i <= y; i++) { | |
p *= a1; | |
p = p % N; | |
} | |
printf("%d\n", p); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment