zoukankan      html  css  js  c++  java
  • 【反演复习计划】【COGS2433】&&【bzoj3930,CQOI2015选数】爱蜜莉雅的冰魔法

    同bzoj3930。

    (日常盗题图)

    Emilia

    #include<bits/stdc++.h>
    #define N 1000010  
    #define yql 1000000007
    #define ll long long
    using namespace std;
    int n;
    ll m,l,r,k;ll f[N];
    ll Pow(ll x,int y){
        ll ans=1;
        while(y){if (y&1) ans=ans*x%yql;  x=x*x%yql;  y>>=1;  }
        return ans;
    }
    ll read(){
        ll x=0;int f=1;char ch;
        do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
        do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
        return x*f;
    }
    int main(){
        freopen("aimiliyadeicemagic.in","r",stdin);
        freopen("aimiliyadeicemagic.out","w",stdout);
        scanf("%d",&n);k=read();l=read();r=read();
        for (ll i=r-l;i>=1;i--){  
            ll lx=(l-1)/(k*i),rx=r/(k*i);  
            f[i]=(Pow(rx-lx,n)-(rx-lx)+yql)%yql;  
            for (int j=2;i*j<=r-l;j++)  f[i]=(f[i]-f[i*j]+yql)%yql;  
        }  
        if (l<=k&&k<=r) f[1]++;  
        printf("%d
    ",f[1]);  
    }
  • 相关阅读:
    CF238B Boring Partition
    CF1424G Years
    CF995D Game
    CF468C Hack it!
    CF1417A Copy-paste
    CF1417B Two Arrays
    CF849B Tell Your World
    [洛谷P3389][模板]高斯消元法
    CF1225D
    P6687
  • 原文地址:https://www.cnblogs.com/zcysky/p/6893538.html
Copyright © 2011-2022 走看看