STD有误???
...................是我太弱了还是怎么样啊.........公式推对的自己写了怎么交都是百分之55,然后不得已看了std,刚开始对比我的代码没发现错误..然后我发现我把std代码加了有注释的两行就也是百分之55了....那么是不是std就假了啊......所以数据也假了啊.....整个人都是懵逼的啊...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>
inline T read(T&x){
x=0;int f=0;char ch=getchar();
while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x=f?-x:x;
}
const int P=1e9+7;
const int N=600000+10;
ll T,n,m,k,i,ans,f[N],inv[N];
ll ksm(ll a,ll n){
ll res=1;
a%=P;
while (n){
if (n&1) res=res*a%P;
a=a*a%P;
n>>=1;
}
return res;
}
ll C(ll n,ll m){
if (n<m) return 0;
ll res=1;
for (int i=1;i<=m;i++){
ll a=(n-m+i)%P;
ll b=i%P;
res=res*(a*ksm(b,P-2)%P)%P;
}
return res;
}
ll lucas(ll n,ll m){
if (m==0) return 1;
return C(n%P,m%P)*lucas(n/P,m/P)%P;
}
int main(){
cin>>n>>m>>k;
ll N0=lucas(m+n-1,n-1);
ll nn=(n+m+1)/(k+1);
for (i=1;i<=nn;++i){
ans+=pow(-1,i+1)*lucas(n,i)*lucas((n+m-1)-(i*(k+1)),(n-1));
ans%=P;
}
(N0-=ans)%=P;//修改的地方
if (N0<0) N0+=P;//修改的地方
printf("%lld\n",N0);
return 0;
}
叮咚买菜工作强度 246人发布