传送门

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

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

  

codeforces776E的更多相关文章

随机推荐

  1. react native ios启动指定模拟器

    react-native run-ios --simulator "iPhone 7 Plus” xcrun instruments -w 'iPhone X'

  2. VUE之命令行报错:Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead 解决办法

    Failed to compile. ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-5992 ...

  3. Codeforces Gym101606 D.Deranging Hat (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))

    D Deranging Hat 这个题简直了,本来想的是冒泡排序然后逆着输出来的,后来发现不对,因为题目上求的是最优解,而且冒泡的话,输出结果有的超出10000行了,所以就是把一开始的,排好序的字母标 ...

  4. k8s-pod的生命周期

    1.pod资源-spec.containers - name:镜像运行起来之后叫容器,该字段为容器名 image:镜像名字 imagePullPolicy:表示从哪拉取镜像, Always:不管本地有 ...

  5. Spring配置项之<aop:aspectj-autoproxy />

    通过配置织入@Aspectj切面 虽然可以通过编程的方式织入切面,但是一般情况下,我们还是使用spring的配置自动完成创建代理织入切面的工作. 通过aop命名空间的<aop:aspectj-a ...

  6. 【转载】Websocket学习

    首先是在Tomcat里面看到Websocket的演示.很有意思. http://localhost:8080/examples/websocket/index.xhtml 里面有: Echo exam ...

  7. 【Unity3D自学记录】Unity3D之自制小钟表

    今天来写一个小钟表,事实上非常easy,就运用到了欧拉角. 首先创建时钟.分钟.秒钟以及4个点(12点.3点.6点.9点)偷懒了~~没弄那么多点. 时钟.分钟.秒钟这三个父级的中心一定要注意,我们旋转 ...

  8. 面试之SQL(1)--选出选课数量&gt;=2的学号

    ID      Course 1 AA 1 BB 2 AA 2 BB 2 CC 3 AA 3 BB 3 CC 3 DD 4 AA NULL NULL 选出选课数量>=2的学号 select di ...

  9. 关于mysql engine(引擎)的疑问

    http://bbs.chinaunix.net/thread-989698-1-1.html

  10. vim 自动补全

    1. vim编辑器自带关键字补全 触发: ctrl + n  or ctrl + p 补全命令: <C-n>              普通关键字 [能够根据buffer以及标签文件列表等 ...