http://oj.acm.zstu.edu.cn/JudgeOnline/problem.php?id=4391
题解:快速幂+数学
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
LL a,b,c;
LL qpow(LL x,LL k)
{
LL tem=1LL;
while(k)
{
if(k&1)
tem=(tem*x)%c;
x=(x*x)%c;
k>>=1;
}
return tem;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld%lld",&a,&b,&c);
LL ans=(((a+5)*((qpow(2,b)%c-1)))%c-(5*b)%c)%c;
printf("%lld\n",(ans+c)%c);
}
}