AcWing
  • 首页
  • 题库
  • 题解
  • 分享
  • 问答
  • 活动
  • 应用
  • 吐槽
  • 登录/注册

AcWing 1290. 越狱

作者: 作者的头像   wyc1996 ,  2021-01-11 17:02:22 ,  阅读 7


1


组合数的计算

分析题意,最终的答案就是所有可能的情况减去不存在冲突的情况:即$ M^N -(M-1)^{N-1} $

#include<iostream>

using namespace std;
const int mod=100003;
typedef long long LL;

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

int main()
{
    LL m,n;
    cin>>m>>n;
    cout<<((qmi(m,n)-m*qmi(m-1,n-1))%mod+mod)%mod<<endl;
    return 0;
}

0 评论

你确定删除吗?

© 2018-2021 AcWing 版权所有  |  京ICP备17053197号-1
联系我们  |  常见问题
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息