Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save henrybear327/4cee24baa0719b4b738a to your computer and use it in GitHub Desktop.
Save henrybear327/4cee24baa0719b4b738a to your computer and use it in GitHub Desktop.
w2c(new with help from stack overflow).c
#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