题目链接:http://codeforces.com/problemset/problem/776/E


${\because gcd(i,n-i)=1\Leftrightarrow gcd(i,n)=1}$

${\therefore f(x)=\phi (x)}$

${\because \sum_{d|x}\phi(d)=x}$

${\therefore g(x)=x}$

问题转换为求${\phi(\phi(\phi(...)))}$嵌套${\left \lfloor \frac{k}{2} \right \rfloor}$层。

考虑这样的嵌套至多${log}$次就会到$1$,所以直接暴力做就可以了。


 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg long long
#define md 1000000007
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout); llg phi(llg x)
{
llg m=sqrt(x+0.5);
llg ans=x;
for (llg i=;i<=m;i++)
if (x%i==)
{
ans=ans/i*(i-);
while (x%i==) x/=i;
}
if (x>) ans=ans/x*(x-);
return ans;
}
llg n,m,k; int main()
{
yyj("E");
cin>>n>>k;
llg ans=phi(n);
for (llg i=;i<=k;i++)
{
if (i%) ans=phi(ans);
if (ans==phi(ans)) break;
}
cout<<ans%md;
return ;
}

Codeforces 776E The Holmes Children的更多相关文章

  1. Codeforces 776E: The Holmes Children (数论 欧拉函数)

    题目链接 先看题目中给的函数f(n)和g(n) 对于f(n),若自然数对(x,y)满足 x+y=n,且gcd(x,y)=1,则这样的数对对数为f(n) 证明f(n)=phi(n) 设有命题 对任意自然 ...

  2. 【codeforces 776E】The Holmes Children

    [题目链接]:http://codeforces.com/contest/776/problem/E [题意] f(n)是小于n的不同整数对(x,y)这里x+y==n且gcd(x,y)==1的个数; ...

  3. Codeforces_776E: The Holmes Children (数论 欧拉函数)

    题目链接 先看题目中给的函数f(n)和g(n) 对于f(n),若自然数对(x,y)满足 x+y=n,且gcd(x,y)=1,则这样的数对对数为f(n) 证明f(n)=phi(n) 设有命题 对任意自然 ...

  4. Codeforces 1063D Candies for Children

    题目大意 给定整数 $n, k, l, r$,$1\le n, k \le 10^{11}$,$1\le l, r \le n$ . 令 $ m = r - l + 1$,若 $m \le 0$,$m ...

  5. ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined)

    前四题比较水,E我看出是欧拉函数傻逼题,但我傻逼不会,百度了下开始学,最后在加时的时候A掉了 AC:ABCDE Rank:182 Rating:2193+34->2227 终于橙了,不知道能待几 ...

  6. Codeforces Round #400 (Div. 1 + Div. 2, combined)——ABCDE

    题目戳这里 A.A Serial Killer 题目描述似乎很恶心,结合样例和样例解释猜测的题意 使用C++11的auto可以来一手骚操作 #include <bits/stdc++.h> ...

  7. Codeforces Round #257 (Div. 2) A. Jzzhu and Children(简单题)

    题目链接:http://codeforces.com/problemset/problem/450/A ------------------------------------------------ ...

  8. Codeforces Round #257 (Div. 2/A)/Codeforces450A_Jzzhu and Children

    解题报告 没什么好说的,大于m的往后面放,,,re了一次,,, #include <iostream> #include <cstdio> #include <cstri ...

  9. Codeforces#543 div2 B. Mike and Children(暴力?)

    题目链接:http://codeforces.com/problemset/problem/1121/B 题意 给n个数 最多的对数 其中每一对(i,j)的ai+aj都相等(不知道怎么解释.... 判 ...

随机推荐

  1. html5的理解

    1.良好的移动性,以移动设备为主 2.响应式设计,以适应自动变化的屏幕尺寸 3.支持离线缓存技术,webStorage本地缓存 4.新增canvas.video.audio等新标签元素,新增特殊内容元 ...

  2. 在win10下安装eclipse

    1.在官网下载jdk.目前最新版本为jdk8. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-21331 ...

  3. window bat 运行 cmd 命令

    新建一个.bat批处理文件,编写以下切换目录 并且执行 ipconfig 命令: cmd /k "cd /d D:phpStudy/WWW & ipconfig" cmd ...

  4. 给PHP开启shmop扩展实现共享内存

    在项目开发中,想要实现PHP多个进程之间共享数据的功能,让客户端连接能够共享一个状态,需要开启共享内存函数shmop.如果预期考虑会遇到这方面需求,那么最好在编译PHP的时候添加--with-shmo ...

  5. Fiddler(一)Fiddler介绍及应用场景

    Fiddler是一款网络抓包工具,抓包可以是抓取电脑端请求的数据,还可以抓取移动端(手机APP)的数据包,可以监控HTTP和HTTPS的流量,可以通过浏览器或者客户端软件向服务器发送的HTTP或者HT ...

  6. netstat -ano输出中的ESTABLISHED off

    今天,我们性能测试的环境出现个奇怪现象,通过oci direct load回库的进程似乎僵死了,应用端cpu 200%(两个线程在跑,一个是一直在ocidirectload没反应,另外一个是正在sem ...

  7. What is probabilistic programming? | 中文翻译

    What is probabilistic programming? | 中文翻译 Probabilistic languages can free developers from the compl ...

  8. Python3.6.2在线安装pymysql模块

    我是一个python新手刚才使用python写邮件发送代码的时候想着需要连接数据库, 下面的安装步骤 python -m pip install pymysql PS C:\Users\hp> ...

  9. python --- 25 模块和包

    一.模块 1.导入方式 自己创建的模块名称 切不可和 内置模块的一样 ①  import  模块 ②  import 模块 as  名      设置在此空间的名称 ③  from 模块 import ...

  10. ODAC(V9.5.15) 学习笔记(四)TOraDataSet

    名称 类型 说明 SequenceMode TSequenceMode ODAC可以直接利用Oracle中的序列对象为表的主键赋值,从而实现主键自动增长的功能.该属性决定了在什么场合下使用序列: sm ...