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. jQuery插件开发的模式和结构

    jQuery插件开发 一般来说,jQuery插件的开发分为两种:一种是挂在jQuery命名空间下的全局函数,也可称为静态方法:另一种是jQuery对象级别的方法,即挂在jQuery原型下的方法,这样通 ...

  2. js代码大全

    超级实用且不花哨的js代码大全 事件源对象event.srcElement.tagNameevent.srcElement.type 捕获释放event.srcElement.setCapture() ...

  3. 【树莓派2B倒腾日志】之安装系统及配置

    15号树莓派到手到现在,折腾了也有一小周,自己摸索着,装了系统,登上SSH,更新了源,连了VNC,换上wifi,亮了小灯.再到今天捣鼓了下数码管,回头想想,该写个日志记录一下这一周的所得,自己总结也方 ...

  4. python中的静态方法和类方法

    在python中,各种方法的定义如下所示: class MyClass(object): #在类中定义普通方法,在定义普通方法的时候,必须添加self def foo(self,x): print & ...

  5. JQuery中的事件以及动画

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

  6. Java 面向对象概念

    Interface 接口 An interface defines a protocol of communication between two objects. An interface decl ...

  7. .NET异步编程初识async与await

    这是两个关键字,用于异步编程.我们传统的异步编程方式一般是Thread.ThreadPool.BeginXXX.EndXXX等等.把调用.回调分开来,代码的逻辑是有跳跃的,于是会导致思路不是很清晰的问 ...

  8. Ruby on Rails vs. PHP vs. Python

    开发者在开发web应用时,往往会对平台的选择感到困惑,而web专家通常会建议:要考虑几个因素,这些因素包括周转时间.质量.跨浏览器兼容性.与其他框架的整合.数据安全性.易于访问性等. 在考虑了这些因素 ...

  9. HDU5873:Football Games

    题目链接: Football Games 分析: 先将分数排序,然后 设当前队编号为p,设个指针为p+1,然后p>1,每次p-=2,指针右移一位p==1,指针指向的队-=1p==0,从指针开始到 ...

  10. (原创)jquery插件-可选可填控件

    ;(function ($) { $.fn.autoFillTextBox = function (options) { var defaults = { nShow: 5, //显示条数 nLen: ...