标签:stack ret can turn argc vector pac pre ++
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstring> 5 #include <algorithm> 6 #include <queue> 7 #include <stack> 8 #include <vector> 9 using namespace std; 10 int main(int argc, char *argv[]) 11 { 12 int t; 13 scanf("%d",&t); 14 while(t--) 15 { 16 int m,k; 17 long long sum=0; 18 scanf("%d%d",&m,&k); 19 for(int i=0;i<k;i++) 20 { 21 long long x,n; 22 scanf("%lld%lld",&x,&n); 23 long long sum1=1; 24 while(n>0) 25 { 26 if(n&1) 27 sum1=(sum1*x)%m; 28 x=(x*x)%m; 29 n>>=1; 30 } 31 sum=(sum+sum1)%m; 32 } 33 printf("%lld\n",sum); 34 } 35 return 0; 36 }
标签:stack ret can turn argc vector pac pre ++
原文地址:https://www.cnblogs.com/huluxin/p/9749043.html