zoukankan      html  css  js  c++  java
  • codeforces776E

    传送门

    这题看着很唬人,但实际上是道水题...

    f[n]通过打表或证明,可以发现就是欧拉函数,g[n]恒等于n,所以题目的意思就是让你求n的k次欧拉函数。

    可以发现实际上k次欧拉函数,n的数值减小得很快,所以直接暴力即可。

    code:真的暴力

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<ctime>
    #include<algorithm>
    #include<iomanip>
    #include<queue>
    #include<set>
    #include<map>
    #include<vector>
    using namespace std;
    #define LL  long long
    #define FILE "dealing"
    #define up(i,j,n) for(LL i=j;i<=n;i++)
    LL read(){
    	LL x=0,f=1,ch=getchar();
    	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
    	return x*f;
    }
    const LL maxn=1600000,mod=1000000007,inf=1000000000;
    bool cmin(LL& a,LL b){return a>b?a=b,true:false;}
    bool cmax(LL& a,LL b){return a<b?a=b,true:false;}
    LL c[maxn],r[maxn],cnt=0;
    LL mul(LL a,LL b){LL ans=1;for(;b;a*=a,b>>=1)if(b&1)ans*=a;return ans;}
    LL qiuoula(LL n){
    	LL m=(LL)sqrt(n*1.0+1),sum=1;
    	cnt=0;
    	up(i,2,m){
    		if(n==1)break;
    		while(n%i==0){
    			n/=i;
    			if(c[cnt]==i)r[cnt]++;
    			else c[++cnt]=i,r[cnt]=1;
    		}
    		if(c[cnt]==i)
    			sum*=(mul(c[cnt],r[cnt])-mul(c[cnt],r[cnt]-1));
    	}
    	if(n>1)sum*=(n-1);
    	return sum;
    	
    }
    int main(){
    	//freopen(FILE".in","r",stdin);
    	//freopen(FILE".out","w",stdout);
    	LL n=read(),m=(read()+1)/2;
    	up(i,1,m){
    		n=qiuoula(n);
    		if(n==1)break;
    	}
    	cout<<n%mod<<endl;
    	return 0;
    }
    

      

  • 相关阅读:
    Developers’ Musthave: the new Microsoft AllInOne Code Framework Sample Browser and 3500+ samples
    8774
    DCOM
    9个最棒的代码片段资源网站
    WCF中的几种地址总结
    如何用C#编写DCOM服务器
    C++ DCOM服务器和C#客户端互操作完全解释
    理解Prism中MVVM的Command与CommandParameter
    WCF REST 基础教程
    细说ASP.NET Forms身份认证
  • 原文地址:https://www.cnblogs.com/chadinblog/p/6437646.html
Copyright © 2011-2022 走看看