#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e7;
const int mod=1e8+7;
int v[maxn+50];
int f[maxn+50];
int n,m;
void prepare()
{
memset(v,0,sizeof(v));
for(int i=2; i<=maxn; i++)
{
if(!v[i])
for(int j=2*i; j<=maxn; j+=i)
v[j]=1;
}
}
int main()
{
prepare();
f[1]=1;f[2]=1;
for(int i=3;i<=maxn;i++)
f[i]=(long long)f[i-1]*(v[i]?i:i-1)% mod;
while(scanf("%d%d",&n,&m)==2&&n)
{
int ans=f[m];
for(int i=m+1;i<=n;i++)
ans=(long long)ans*i%mod;
printf("%d\n",(ans-1+mod)%mod);
}
return 0;
}
UVA 11440(p338)----Help Mr.Tomisu
最新推荐文章于 2021-04-20 16:06:28 发布