GTW likes function

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5596

Description

Now you are given two definitions as follows.

f(x)=∑xk=0(−1)k22x−2kCk2x−k+1,f0(x)=f(x),fn(x)=f(fn−1(x))(n≥1)

Note that φ(n) means Euler’s totient function.(φ(n)is an arithmetic function that counts the positive integers less than or equal to n that are relatively prime to n.)

For each test case, GTW has two positive integers — n and x, and he wants to know the value of the function φ(fn(x)).

Input

There is more than one case in the input file. The number of test cases is no more than 100. Process to the end of the file.

Each line of the input file indicates a test case, containing two integers, n and x, whose meanings are given above. (1≤n,x≤1012)

Output

In each line of the output file, there should be exactly one number, indicating the value of the function φ(fn(x)) of the test case respectively.

Sample Input

1 1

2 1

3 2

Sample Output

2

2

2

Hint

题意

题解:

一切反动派都是纸老虎

打表之后很容易发现,f(x) = x+1

于是这道题就很蠢了,直接输出phi(n+x+1)就好了

代码

#include<iostream>
#include<stdio.h>
using namespace std; long long phi(long long n)
{
long long tmp=n;
for(long long i=2;i*i<=n;i++)
if(n%i==0)
{
tmp/=i;tmp*=i-1;
while(n%i==0)n/=i;
}
if(n!=1)tmp/=n,tmp*=n-1;
return tmp;
} int main()
{
long long n,x;
while(scanf("%I64d%I64d",&n,&x)!=EOF)
printf("%I64d\n",phi(x+n+1));
return 0;
}

HDU 5597 GTW likes function 打表的更多相关文章

  1. HDU 5597 GTW likes function 欧拉函数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5597 题意: http://bestcoder.hdu.edu.cn/contests/contes ...

  2. HDU5597/BestCoder Round #66 (div.2) GTW likes function 打表欧拉函数

    GTW likes function      Memory Limit: 131072/131072 K (Java/Others) 问题描述 现在给出下列两个定义: f(x)=f_{0}(x)=\ ...

  3. hdu-5597 GTW likes function(欧拉函数+找规律)

    题目链接: GTW likes function Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 131072/131072 K (J ...

  4. HDU 5596 GTW likes gt 倒推

    GTW likes gt 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5596 Description Long long ago, there w ...

  5. HDU 5596 ——GTW likes gt——————【想法题】

    GTW likes gt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)To ...

  6. hdu 5596 GTW likes gt

    题目链接: hdu 5596 题意不难懂(虽然我还是看了好久)大概就是说 n 个人排成一列,分成两组, 第 i 秒时第 i 个人会消灭掉前面比他 b[i] 值低的且和他不同组的人,c[i] 表示第 c ...

  7. Hdu 5595 GTW likes math

    题意: 问题描述 某一天,GTW听了数学特级教师金龙鱼的课之后,开始做数学<从自主招生到竞赛>.然而书里的题目太多了,GTW还有很多事情要忙(比如把妹),于是他把那些题目交给了你.每一道题 ...

  8. hdu 5595 GTW likes math(暴力枚举查询)

    思路:直接暴力枚举区间[l,r]的整数值,然后max和min就可以了. AC代码: #pragma comment(linker, "/STACK:1024000000,1024000000 ...

  9. HDU 5596/BestCoder Round #66 (div.2) GTW likes math 签到

    GTW likes math  Memory Limit: 131072/131072 K (Java/Others) 问题描述 某一天,GTW听了数学特级教师金龙鱼的课之后,开始做数学<从自主 ...

随机推荐

  1. Effective java笔记8--序列化

    对象的序列化(object serialization)API,它提供了一个框架,用来将对象编码成一个字节流,以及从字节流编码中重新构建对象. 一.谨慎地实现Serializable     要想使一 ...

  2. C++ STL算法系列5---equal() , mismatch()

    equal和mismatch算法的功能是比较容器中的两个区间内的元素.这两个算法各有3个参数first1,last1和first2.如果对 于区间[first1,last1)内所有的first1+i, ...

  3. SPF详解

    什么是SPF? 这里的SPF不是防晒指数,而是指Sender Policy Framework.翻译过来就是发信者策略架构,比较拗口,通常都直接称为SPF. SPF是跟DNS相关的一项技术,它的内容写 ...

  4. Visual Studio 2005 移植 - WINVER,warning C4996, error LINK1104

    Visual Studio 2005 移植 - WINVER,warning C4996, error LINK1104 一.WINVER  Compile result:  WINVER not d ...

  5. dzzoffice的树型结构用户管理设计

    在DzzOffice1.1的开发中,针对用户使用群体重新设计了,机构.部门.用户管理应用. 传统OA,企业相关程序,一般是设置机构-设置部门-设置职位-添加用户这样的步骤.每个步骤分为不同的管理界面. ...

  6. bzoj3620 似乎在梦中见过的样子

    好久没有写过KMP了,今天写个KMP练练手.此题就是枚举左端点暴力,用KMP做到O(n^2) #include<cstdio> #include<cstring> using ...

  7. 修改ssh服务的默认端口

    修改ssh服务的默认端口 1.查看当前服务端口 一般ssh服务的默认端口为22端口,查看监听的端口用netstat,如下: [root@ansiblemoniter ~]# netstat -tnlp ...

  8. MySQL Connector_J_5.1.34_2014.10

    5.1版本符合JDBC3.0和JDBC4.0规范 跟MySQL4.1-5.7兼容 5.1.21以后支持JDK7的JDBC4.1规范 在MySQL4.1之前,是不支持utf8的 com.mysql.jd ...

  9. 《Genesis-3D开源游戏引擎--横版格斗游戏制作教程08:虚拟键盘实现》--本系列完结

    8.虚拟键盘实现 概述: 硬键盘就是物理键盘,平时敲的那种.软键盘是虚拟的键盘,不是在键盘上,而是在"屏幕"上.虚拟按键就是虚拟键盘的一部分,根据功能需求,提供部分按键效果的UI可 ...

  10. android get uuid获取uuid

    https://github.com/Paldom/UniqueDeviceID protected void getDeviceUUID(){ try { Context context = cor ...