Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //p^q mod c = ?
- #include<stdio.h>
- int main()
- {
- int p,q,c,t;
- scanf("%d",&t);
- for(int i = 0; i<t; i++)
- {
- scanf("%d %d %d", &p,&q,&c);
- }
- int temp = 1;
- for(int j = 1; j<=q; j++)
- {
- temp *= p;
- }
- int res = temp % c;
- printf("Result = %d\n",res);
- for(int j= 1; j<=q; j++)
- {
- temp *= p;
- temp %= c;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment