zoukankan      html  css  js  c++  java
  • bzoj3930

    题解:

    莫比乌斯函数

    然而向我这种弱菜肯定选择暴力dp

    代码:

    #include<bits/stdc++.h>
    const int N=100010,M=1000000007;
    typedef long long ll;  
    using namespace std;  
    int n;  
    ll m,L,R,k,f[N];   
    ll power(ll x,int y)  
    {  
        ll ans=1;  
        while (y)  
         {  
            if (y&1)ans=ans*x%M;  
            x=x*x%M;  
            y>>=1;  
         }  
        return ans;  
    }  
    int main()  
    {  
        scanf("%d%lld%lld%lld",&n,&k,&L,&R);  
        for (ll i=R-L;i>=1;i--)  
         {  
            ll l=(L-1)/(k*i),r=R/(k*i);  
            f[i]=(power(r-l,n)-(r-l)+M)%M;  
            for (int j=2;i*j<=R-L;j++)f[i]=(f[i]-f[i*j]+M)%M;  
         }  
        if (L<=k&&k<=R)f[1]++; 
        printf("%d
    ",f[1]);  
        return 0;  
    }  
  • 相关阅读:
    活动安排问题
    完美字符串
    Codeforces Round #696 (Div. 2) 解题报告
    Codeforces 1459D
    Codeforces 25D
    POJ 1847
    LightOJ 1074
    POJ 3159
    POJ 1511
    POJ 1502
  • 原文地址:https://www.cnblogs.com/xuanyiming/p/8665129.html
Copyright © 2011-2022 走看看