题目大意:给定偶数张牌,问m次洗牌之后第l张牌是多少

x*2^m==l (mod n+1)
x=(n/2+1)^m*l mod n+1

快速幂+快速乘233

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MOD (n+1)
using namespace std;
typedef unsigned long long ll;
long long n,m,l;
ll Quick_Multiplication(ll x,ll y)
{
	ll re=0;
	while(y)
	{
		if(y&1) re+=x,re%=MOD;
		x+=x,x%=MOD;y>>=1;
	}
	return re;
}
ll Quick_Power(ll x,ll y)
{
	ll re=1;
	while(y)
	{
		if(y&1) re=Quick_Multiplication(re,x);
		x=Quick_Multiplication(x,x);y>>=1;
	}
	return re;
}
int main()
{
	cin>>n>>m>>l;
	cout<<Quick_Multiplication(Quick_Power(n/2+1,m),l)%MOD<<endl;
}