【BZOJ1005】明明的烦恼
【BZOJ1007】水平可见直线

【BZOJ1008】越狱

Zarxdy34 posted @ 2015年9月24日 21:20 in BZOJ with tags 组合数学 , 522 阅读

  很少刷到这么水的题了...

  答案就是总方案数-无法越狱的方案数。

 

#include <cstdio>
typedef long long LL;
using namespace std;
const int mod=100003;

LL Pow(LL a,LL b)
{
	LL res=1;
	a%=mod;
	while (b)
	{
		if (b&1) res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

LL n,m;

int main()
{
	scanf("%lld%lld",&m,&n);
	printf("%lld\n",(Pow(m,n)-(m*Pow(m-1,n-1))%mod+mod)%mod);
	return 0;
}

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter