码迷,mamicode.com
首页 > 其他好文 > 详细

BZOJ 1008:[HNOI2008]越狱

时间:2017-09-16 19:09:24      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:hnoi2008   str   view   mat   lap   play   base   cto   amp   

傻逼题,然后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]越狱

标签:hnoi2008   str   view   mat   lap   play   base   cto   amp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!