x*2^m==l (mod n+1)
x=(n/2+1)^m*l mod n+1
#include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<cmath> #include<queue> using namespace std; typedef long long LL; #define MOD (LL)(n+1LL) int n,m,l; LL qpow(LL a,LL b) { LL m=a,s=1LL; while (b) { if (b & 1) s=(s*m)%(n+1); m=(m*m)%(n+1); b>>=1; } return s; } int main() { scanf("%d%d%d",&n,&m,&l); printf("%lld",(qpow((LL)n/2+1,m)*l)%(n+1)); return 0; }
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using
namespace
std;
typedef
long
long
LL;
#define MOD (LL)(n+1LL)
int
n,m,l;
LL qpow(LL a,LL b)
{
LL m=a,s=1LL;
while
(b)
{
if
(b & 1)
s=(s*m)%(n+1);
m=(m*m)%(n+1);
b>>=1;
}
return
s;
}
int
main()
{
scanf
(
"%d%d%d"
,&n,&m,&l);
printf
(
"%lld"
,(qpow((LL)n/2+1,m)*l)%(n+1));
return
0;
}
时间: 2024-11-07 19:04:29