zoukankan      html  css  js  c++  java
  • P6788 「EZEC-3」四月樱花

    P6788 「EZEC-3」四月樱花

    链接

    P6788 「EZEC-3」四月樱花

    题解

    难点只有一个:(y^{d(y)}) (=) (prod_{t|y} y) (=) (prod_{t|y} t cdot frac{y}{t}) (=) (prod_{t|y} t^{2})
    然而这点我整场月赛都没想出来,技不如人甘拜下风。有了这个式子之后式子就随便推了。
    出题人似乎稍微卡了一下(O(n^{3/4})) 的整除分块。。我卡了下常就过了。。

    (Code)

    #include <bits/stdc++.h>
    #define LL long long
    #define ull unsigned long long
    using namespace std;
    const int N=1e6+10;
    int read(){
        int x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    void print(LL x){
        if(x>9) print(x/10);
        putchar(x%10+'0');
    }
    
    unsigned int n,P,pp;
    
    LL sol(unsigned int x){
    	LL re=0;
    	unsigned int y,z=sqrt(x);
    	for(unsigned int i=1;i<=z;++i){
    		y=x/i;
    		re+=y;
    	}
    	for(unsigned int i=z+1,j;i<=x;i=j){
    		y=x/i;
    		j=x/y+1;
    		re+=(LL)y*(j-i);
    	}
    	return re%pp;
    }
    LL qpow(LL x,LL y){
    	LL re=1;
    	while(y){
    		if(y&1) re=re*x%P;
    		x=x*x%P;y>>=1;
    	}
    	return re;
    }
    int main(){
    	cin>>n>>P;pp=P-1;
    	unsigned int y,z;
    	LL ans=1;
    	for(unsigned int i=1,j;i<=n;i=j+1){
    		z=n/i;
    		j=n/z;
    		y=sol(z);
    		ans=ans*qpow((LL)i*qpow(j+1,P-2)%P,y)%P;
    	}
    	ans=ans*ans%P;
    	cout<<ans<<endl;
    	return 0;
    }
    
  • 相关阅读:
    50 系统调用的实现
    49 进程调度预备开发(下)
    48 进程调度预备开发(上)
    47 多进程并行执行(下)
    IIC总线
    46 多进程并行执行(上)
    45 内核中的中断处理(下)
    解决错误/usr/bin/ld: cannot find -lz
    rsync只传输隐藏文件
    Firewall命令
  • 原文地址:https://www.cnblogs.com/Yuigahama/p/13608694.html
Copyright © 2011-2022 走看看