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. nginx upstream的分配方式

    1.轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除. 2.weight 指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况. 例 ...

  2. jQuery 关于点击菜单项,使子条目“向上”展开效果的实现

    为什么做了这样一个的功能呢?原因是前一段时间jQuery群里有个朋友想实现这样一个东东,大家都知道jQuery中有现成的slideDown和slideUp方法,但那是向下展开,而这个是一个完全相反的效 ...

  3. JQuery中的事件以及动画

    .bind事件 <script src="script/jquery-1.7.1.min.js"></script> <script> $(fu ...

  4. MFC中GetPrivateProfileString相关函数

    项目中用到了这个函数,所以了解了一下,参考了一些博客: http://blog.sina.com.cn/s/blog_a599b5960101tsbk.html http://blog.csdn.ne ...

  5. C/C++——C++变量的作用域与生命周期,C语言中变量的作用域和生命周期

    全局变量 作用域:全局作用域(全局变量只需在一个源文件中定义,就可以作用于所有的源文件.) 生命周期:程序运行期一直存在 引用方法:其他文件中要使用必须用extern 关键字声明要引用的全局变量. 内 ...

  6. RVM 安装&卸载

    安装: curl -L https://get.rvm.io | bash -s stable --autolibs=enabled [--ruby] [--rails] [—trace] $ cur ...

  7. Linux入门视频

    为了方便新手学习Linux,本人专门录制了以下Linux初级视频方便学习,本系列多媒体教程已完成的博文: 轻松学习Linux之入门篇 http://chenguang.blog.51cto.com/3 ...

  8. koa redis 链接

    koa 是新一代框架 npm install koa-redis 代码如下 var koa = require('koa'); var http = require('http'); var sess ...

  9. SharePoint咨询师之路:设计之前的那些事三:体系结构

    提示:本系列只是一个学习笔记系列,大部分内容都可以从微软官方网站找到,本人只是按照自己的学习路径来学习和呈现这些知识.有些内容是自己的经验和积累,如果有不当之处,请指正. 咨询师更多的时候是解决方案提 ...

  10. 在VS2012中实现Ext JS的智能提示

    Visual Studio 2012太强大了,居然能自己会去提取Ext JS的类的属性和方法,从而实现只能提示.下面就来介绍一下实现这个功能. 在Visual Studio 2012中随便创建一个We ...