This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
long long mans,c,mul[1000003],fac[1000003],a,b,i,j,s=1,ans,X=1e9+7;
main()
{
scanf("%lld%lld",&a,&b);
if(b>=a)
{
printf("0");return 0;
}
for(;b<=a-1;){
b++;ans=0;
mul[a-b+1]=1;
for(i=a-b;i>=1;i--)
{
mul[i]=mul[i+1]*i%X;
}
fac[0]=1;
for(i=1;i<=a;i++)fac[i]=fac[i-1]*i%X;
for(i=1;i<=a&&a-i>=0&&a-b+2-i>=1;i++)
{
ans+=i*b%X*fac[a-i]%X*mul[a-b+2-i]%X;
ans%=X;
}
mans+=ans*(a-b+1)%X;
mans%=X;
}
printf("%lld",mans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |