传送门

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

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. 51Nod 1239 欧拉函数前n项和 杜教筛

    http://www.51nod.com/Challenge/Problem.html#!#problemId=1239 AC代码 #include <bits/stdc++.h> #de ...

  2. CODECHEF Oct. Challenge 2014 Children Trips

    @(XSY)[分塊, 倍增] Description There's a new trend among Bytelandian schools. The "Byteland Tourist ...

  3. java正则过虑字符

    public static void main(String[] args) { String testrString = "{\"abc\" : \"[123 ...

  4. K-L变换

    K-L变换( Karhunen-Loeve Transform)是建立在统计特性基础上的一种变换,有的文献也称为霍特林(Hotelling)变换,因他在1933年最先给出将离散信号变换成一串不相关系数 ...

  5. c语言函数---I

    函数名: imagesize 功 能: 返回保存位图像所需的字节数 用 法: unsigned far imagesize(int left, int top, int right, int bott ...

  6. C# 将链表存入二进制文件及读取二进制文件得到链表示例

    // 将tasks保存到二进制文件中 public Boolean saveToFile(String file) { try { ) { // 没任务就不存 return false; } if ( ...

  7. CString和string头文件

    在使用了MFC库的工程中CString可以直接使用,在没有使用MFC库的工程中加入#include <atlstr.h> 要使用STL里的string,要加入#include <st ...

  8. js 字符串常用方法

    数组方面 1.push:向数组尾部增加内容,返回的是新数组的长度. var arr = [1,2,3]; console.log(arr); var b = arr.push(4); console. ...

  9. cas 单点登录(SSO)之中的一个: jasig cas-server 安装

    cas 单点登录(SSO)实验之中的一个: jasig cas-server 安装 參考文章: http://my.oschina.net/indestiny/blog/200768#comments ...

  10. 【转载】ASP.NET应用程序与页面生命周期

    在本文中,我们将了解不同的事件,ASP.NET 应用程序的生命周期以浏览器向 Web 服务器(对于 ASP.NET 应用程序,通常为 IIS)发送请求为起点,直至将请求结果返回至浏览器结束.在这个过程 ...