P1999 50分求调
查看原帖
P1999 50分求调
1285171
ruishou楼主2024/10/7 13:50

代码↓

#include<bits/stdc++.h>
using namespace std;
#define p 1000000007
#define int long long
int f[100010],n,m;
int powmodp(int a,int b){
    int ans=1;
    while(b>0){
        if(b&1)ans=(1ll*ans*a)%p;
        a=(1ll*a*a)%p;
        b>>=1;
    }
    return ans;
}
signed main(){
    cin >> n >> m;
    if(m>n){cout << 0;return 0;}
    f[0]=powmodp(2,n);
    for(int i=1;i<=m;i++)f[i]=(1ll*f[i-1]*n-i+1)%p*powmodp(2*i,p-2)%p;
    cout << f[m];
    return 0;
}

不知道哪里错了

2024/10/7 13:50
加载中...