GTW likes function

 
 

 Memory Limit: 131072/131072 K (Java/Others)
问题描述
现在给出下列两个定义:
f(x)=f_{0}(x)=\sum_{k=0}^{x}(-1)^{k}2^{2x-2k}C_{2x-k+1}^{k},f_{n}(x)=f(f_{n-1}(x))(n\geq 1)f(x)=f​0​​(x)=∑​k=0​x​​(−1)​k​​2​2x−2k​​C​2x−k+1​k​​,f​n​​(x)=f(f​n−1​​(x))(n≥1) \varphi(n)φ(n)为欧拉函数。指的是不超过nn的与nn互质的正整数个数。 对于每组数据,GTW有两个正整数n,xn,x,现在他想知道函数\varphi(f_{n}(x))φ(f​n​​(x))的值。
输入描述
输入有多组数据,不超过100组。每数据输入一行包含2个整数组nn和xx。(1\leq n,x \leq 10^{12})(1≤n,x≤10​12​​)
输出描述
对于每组数据输出一行,表示函数\varphi(f_{n}(x))φ(f​n​​(x))的值。
输入样例
1 1
2 1
3 2
输出样例
2
2
2

题解:按照给出的公式打表,你就会发现其实就是求 n+1+x的欧拉函数值,写个欧拉函数就好了,注意是long long

//meek///#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std ;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
#define fi first
#define se second
#define MP make_pair
typedef long long ll; const int N=+;
const int inf = ;
const int mod= ; ll phi(ll n)
{
ll res=n;
for(ll i=;i*i<=n;i++)
{
if(n%i==)
{
res=res-res/i;
while(n%i==)
n/=i;
}
}
if(n>)
res=res-res/n; //可能还有大于sqrt(n)的素因子
return res;
}
int main() { ll n,x;
while(scanf("%I64d%I64d",&n,&x)!=EOF) {
int ans=;
cout<<phi(x+n+)<<endl;
}
return ;
}

代码

HDU5597/BestCoder Round #66 (div.2) GTW likes function 打表欧拉函数的更多相关文章

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

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

  2. BestCoder Round #66 (div.2)

    构造 1002 GTW likes gt 题意:中文题面 分析:照着题解做的,我们可以倒着做,记一下最大值,如果遇到了修改操作,就把最大值减1,然后判断一下这个人会不会被消灭掉,然后再更新一下最大值. ...

  3. HDU 5597 GTW likes function 打表

    GTW likes function 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5596 Description Now you are give ...

  4. HDU5596/BestCoder Round #66 (div.2) 二分BIT/贪心

    GTW likes gt    Memory Limit: 131072/131072 K (Java/Others) 问题描述 从前,有nn只萌萌的GT,他们分成了两组在一起玩游戏.他们会排列成一排 ...

  5. BestCoder Round #66 (div.2) hdu5592

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

  6. BestCoder Round #66 (div.2) 1002

    GTW likes gt  Accepts: 132  Submissions: 772  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: ...

  7. BestCoder Round #66 (div.2)B GTW likes gt

    思路:一个O(n)O(n)的做法.我们发现b_1,b_2,...,b_xb​1​​,b​2​​,...,b​x​​都加11就相当于b_{x+1},b_{x+2},...,b_nb​x+1​​,b​x+ ...

  8. BestCoder Round #11 (Div. 2) 题解

    HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  9. hdu 5636 搜索 BestCoder Round #74 (div.2)

    Shortest Path  Accepts: 40  Submissions: 610  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: ...

随机推荐

  1. Tutorial: Analyzing sales data from Excel and an OData feed

    With Power BI Desktop, you can connect to all sorts of different data sources, then combine and shap ...

  2. ios中怎么样调节占位文字与字体大小在同一高度

    在设置好字体以后,在占位文字中设置leading这个字体属性,用leading来乘以一个比例(CGFloat)来调节位置.

  3. MS Chart-按照数据库的最大最小时间设置X轴label.

    核心代码: Chart1.ChartAreas[0].AxisX.Interval = (Front_Max - Front_Min).Days / 2; Chart1.ChartAreas[0].A ...

  4. Qt之SQL数据库

    ---------------------------- http://blog.csdn.net/reborntercel/article/details/6991147 http://blog.c ...

  5. 47.MIF和COE文件格式

    .mif和.coe这两个文件分别是Quartus和ISE的RAM和ROM的初始化文件,因此了解他们的格式,是很必要的   MIF文件的格式如下:   WIDTH=14; --数据宽度为14位 DEPT ...

  6. 20.时钟抖动(jitter)和时钟偏移(skew)的概念?

    jitter:由于晶振本身稳定性,电源以及温度变化等原因造成了时钟频率的变化,就是jitter,指的是时钟周期的变化.指两个时钟周期之间存在的差值,这个误差是在时钟发生器内部产生的,和晶振或者PLL内 ...

  7. 一、换系统wince ---到 linux ubuntu 桌面

    今天终于拿到了OK6410,还是比较满意.预装的为wince系统,现要修改为linux 按照  OK6410-A开发板LINUX3.0.1-2013-01用户手册 进行 1.遇到问题.无法写入SD卡( ...

  8. python关于字符串的操作

    #-*- coding:utf-8 -*-#Author:gxli#字符串的操作name=' zhangsan,lisi,wangwu '#分割操作name=name.split(',')print( ...

  9. html转义函数

    public static String filter(String message) { if (message == null) return (null); char content[] = n ...

  10. Github的使用以及Git的简单入门 - 课程作业三

    GitHub创建项目 登录GitHub,在个人主页创建项目(repository) 创建后会生成2个文件,README.md和.gitignore.如图 创建本地仓库 如果是第一次使用git的话,需要 ...