标签:getch 个数 utc getchar char tin cst math www
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define mod 1000000007
#define N 10000007
#define rg register
using namespace std;
inline int read(){
rg int s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
return s*w;
}
inline void write(int x){
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
}
int sum,ans,visit[N],jc[N],ny[N];
inline int ksm(int a,int b){
rg int cnt=1;
while(b){
if(b&1)cnt=1ll*cnt*a%mod;
a=1ll*a*a%mod;
b>>=1;
}
return cnt%mod;
}
inline int C(int n,int m){return n<m?0:1ll*jc[n]*ny[m]%mod*ny[n-m]%mod;}
inline void get_jc(int n){
jc[0]=1;
for(rg int i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%mod;
ny[n]=ksm(jc[n],mod-2);
for(rg int i=n-1;i>=0;--i)ny[i]=1ll*ny[i+1]*(i+1)%mod;
return;
}
inline void get_num(int l,int r){
for(rg int i=l;i<=r;++i){
if(visit[i])continue;
sum++;
for(rg int j=i;j<=r;j+=i)visit[j]=1;
}
return;
}
int main(){
rg int l=read(),r=read(),n=r-l+1;
get_num(l,r),get_jc(r);
for(rg int i=sum;i<=n;++i){
rg int res=1ll*i*sum%mod;
res=1ll*res*jc[i-1]%mod;
res=1ll*res*jc[n-i]%mod;
res=1ll*res*C(n-sum,n-i)%mod;
ans=(ans+res)%mod;
}
write(ans);
return 0;
}
标签:getch 个数 utc getchar char tin cst math www
原文地址:https://www.cnblogs.com/PPXppx/p/10628306.html