Codeforces 776E The Holmes Children
题目链接: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的更多相关文章
- 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) 设有命题 对任意自然 ...
- 【codeforces 776E】The Holmes Children
[题目链接]:http://codeforces.com/contest/776/problem/E [题意] f(n)是小于n的不同整数对(x,y)这里x+y==n且gcd(x,y)==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) 设有命题 对任意自然 ...
- 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 ...
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined)
前四题比较水,E我看出是欧拉函数傻逼题,但我傻逼不会,百度了下开始学,最后在加时的时候A掉了 AC:ABCDE Rank:182 Rating:2193+34->2227 终于橙了,不知道能待几 ...
- Codeforces Round #400 (Div. 1 + Div. 2, combined)——ABCDE
题目戳这里 A.A Serial Killer 题目描述似乎很恶心,结合样例和样例解释猜测的题意 使用C++11的auto可以来一手骚操作 #include <bits/stdc++.h> ...
- Codeforces Round #257 (Div. 2) A. Jzzhu and Children(简单题)
题目链接:http://codeforces.com/problemset/problem/450/A ------------------------------------------------ ...
- Codeforces Round #257 (Div. 2/A)/Codeforces450A_Jzzhu and Children
解题报告 没什么好说的,大于m的往后面放,,,re了一次,,, #include <iostream> #include <cstdio> #include <cstri ...
- Codeforces#543 div2 B. Mike and Children(暴力?)
题目链接:http://codeforces.com/problemset/problem/1121/B 题意 给n个数 最多的对数 其中每一对(i,j)的ai+aj都相等(不知道怎么解释.... 判 ...
随机推荐
- C#使用SmtpClient发送邮件
目的:写一个可发送邮件的DLL. 原理: 例如A使用163邮箱发送邮件给B(qq邮箱).首先A会把邮件通过SMTP(Simple Mail Transfer Protocol)协议传输到163的Smt ...
- mergesort_arithmetic_python
def merge(a, b): c = [] h = j = 0 while j < len(a) and h < len(b): if a[j] < b[h]: c.append ...
- centos 7上nginx+uwsgi 性能调优
上一章将nginx +uwsgi搭建起来,将keystone挂载后面.但是发现一个问题,如果http请求达到一定量后,nginx直接返回502.这让需要部署大规模openstack集群的我很是头疼,比 ...
- java使用wait(),notify(),notifyAll()实现等待/通知机制
public class WaitNotify { static boolean flag=true; static Object lock=new Object(); static class Wa ...
- Golang两种方法实现MD5加密
package main import ( "crypto/md5" "fmt" "io" ) func main() { str := & ...
- mysql 5.7/percona server/mariadb 10.2安装与服务器参数优化
建议使用percona server linux generic版,从https://www.percona.com/downloads/Percona-Server-LATEST/下载,现在不在推荐 ...
- Windows环境下ELK平台的搭建
.背景 日志主要包括系统日志.应用程序日志和安全日志.系统运维和开发人员可以通过日志了解服务器软硬件信息.检查配置过程中的错误及错误发生的原因.经常分析日志可以了解服务器的负荷,性能安全性,从而及时采 ...
- Windows Media Player添加播放插件
- tr 命令用法
tr a. 替换全部字符 [root@bogon scripts]# tr [a-z] [A-Z] < /etc/fstab 将读出的结果全部替换成大写字母 (取一行作为展示效果) ...
- 运行django新的项目,页面总是显示以前的项目,问题解决
运行django新的项目,页面总是显示以前的项目 只需打开任务管理器,再进程中关闭python.exe 再次重新启动服务,python manage.py runserver.即可