首页 > 其他 > 详细

BZOJ 1008:[HNOI2008]越狱

时间:2017-09-16 18:15:56      阅读:234      评论:0      收藏:0      [点我收藏+]

傻逼题,然后n,m写反了WA了一发。。

技术分享
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
typedef long long LL;
using namespace std;
const LL mod=100003;
LL n,m,ans,tp;
LL ksm(LL a,LL b) {
    LL base=a,res=1;
    while(b) {
        if(b&1) (res*=base)%=mod;
        (base*=base)%=mod;
        b>>=1;
    }
    return res;
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%lld%lld",&m,&n);
    ans=ksm(m,n);
    tp=(m*ksm(m-1,n-1))%mod;
    ((ans-=tp)+=mod)%=mod;
    printf("%lld\n",ans);
    return 0;
}
View Code

 

BZOJ 1008:[HNOI2008]越狱

原文:http://www.cnblogs.com/Achenchen/p/7531829.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!