题目链接: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. SSMS登记密码清除

    如图,此界面的登录密码如果要清除,可以找到%AppData%\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin,将SqlStud ...

  2. Web前端学习笔记之离线安装npm

    0x00 概述 这段时间的工作主题就是Linux 下的“离线部署”,包括mongo.mysql.postgresql.nodejs.nginx等软件的离线部署.平常在服务器上借助apt-get就能轻松 ...

  3. ORA-00600: internal error code, arguments: [13030], [20]一例解决

    两年没有接触oracle了,中午,一环境update from的时候出现ORA-00600: internal error code, arguments: [13030], [20]异常,经查,官网 ...

  4. Android之RadioButton多行

    RadioGroup设置orientation="vertical"竖向单列显示 RadioGroup设置orientation="horizontal"横向单 ...

  5. py4CV例子1猫狗大战和Knn算法

    1.什么是猫狗大战: 数据集来源于Kaggle(一个为开发商和数据科学家提供举办机器学习竞赛.托管数据库.编写和分享代码的平台),原数据集有12500只猫和12500只狗,分为训练.测试两个部分. 2 ...

  6. 关于VS2013下制作和使用静态库和动态库

    关于VS2013下制作和使用静态库和动态库 引言 什么是库:库是写好的现有的,成熟的,可以复用的代码. 所谓静态.动态是指链接.将一个程序编译成可执行程序的步骤: 静态库在链接阶段,会将汇编生成的目标 ...

  7. NOIP 车站分级 (luogu 1983 & codevs 3294 & vijos 1851) - 拓扑排序 - bitset

    描述 一条单向的铁路线上,依次有编号为 1, 2, ..., n 的 n 个火车站.每个火车站都有一个级别,最低为 1 级.现有若干趟车次在这条线路上行驶,每一趟都满足如下要求:如果这趟车次停靠了火车 ...

  8. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  9. VC++ 获取exe或者dll版本信息

    #include <iostream> #include <atlstr.h> #pragma comment(lib,"version.lib") CSt ...

  10. 【python005-数据类型】

    数据类型 一.字符串的相加是拼接,数字的相加是求和 二.python的数值类型:整形,浮点型,e记法,布尔类型 >>> 1.2e412000.0>>> 1.2e-4 ...