思路:

移至iwtwiioi    http://www.cnblogs.com/iwtwiioi/p/4986316.html

//By SiriusRen
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long
const int mod=1000000007;
int n,k,l,h,f[100050];
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1)res=res*x%mod;
        x=x*x%mod,y>>=1;
    }return res;
}
signed main(){
    scanf("%lld%lld%lld%lld",&n,&k,&l,&h);
    for(int i=h-l;i;i--){
        int L=(l-1)/(k*i),R=h/(k*i);
        f[i]+=(pow(R-L,n)-R+L+mod)%mod;
        for(int j=2;i*j<=h-l;j++)(f[i]-=f[i*j])%=mod;
        f[i]=(f[i]+mod)%mod;
    }printf("%lld\n",(f[1]+(k>=l&&k<=h))%mod);
}

 

相关文章:

  • 2021-10-09
  • 2022-12-23
  • 2021-10-07
  • 2022-01-24
  • 2022-12-23
  • 2021-07-12
猜你喜欢
  • 2021-10-17
  • 2021-09-12
  • 2022-01-22
  • 2021-06-24
  • 2022-12-23
  • 2021-09-25
  • 2021-08-12
相关资源
相似解决方案