• 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;
    }
    

      

  • 相关阅读:
    gulp-API介绍
    前端构建工具gulpjs的使用介绍及技巧(转载)
    atom插件之less-autocompile
    atom-安装插件
    gulp入门1
    edp 基于node.js和npm的前端开发平台
    (转)详解JavaScript模块化开发
    require.js
    thinkcmf5 iis+php重写配置
    thinkcmf5 模板版变量的加载过程 和 新增网站配置项怎么全局使用
  • 原文地址:https://www.cnblogs.com/chadinblog/p/6437646.html
Copyright © 2020-2023  润新知