HDOJ 5597 GTW likes function (欧拉函数)
GTW likes function
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 226 Accepted Submission(s): 123
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)) .
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)
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define MAXN 60001
#define LL long long
#define INF 0xfffffff
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
using namespace std;
LL eular(LL n)
{ LL i,res=n; for(i=2;i*i<=n;i++) if(n%i==0){ res=res/i*(i-1); while(n%i==0)n/=i; } if(n>1) res=res/n*(n-1); return res;
}
int main()
{LL n,x;while(scanf("%I64d%I64d",&n,&x)!=EOF){printf("%I64d\n",eular(n+x+1));}return 0;
}
HDOJ 5597 GTW likes function (欧拉函数)相关推荐
- hdoj 5597 GTW likes function 【打表找规律】
GTW likes function Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Oth ...
- hdu5597GTW likes function+欧拉函数
Problem Description Now you are given two definitions as follows. f(x)=∑xk=0(−1)k22x−2kCk2x−k+1,f0(x ...
- hdu 5597GTW likes function(欧拉函数)
题目链接:[hdu 5597] f(n)=sum((-1)^k * 2^(2n-2k) * C(k, 2n-k+1)) 0<=k<=n 这个公式化简之后就是f(x) = x+1 简单证 ...
- XTU OJ 1355 Euler‘s Totient Function(欧拉函数)
XTU OJ 1355 Euler's Totient Function(欧拉函数) 题目描述 对于整数n,定义ϕ(n)ϕ(n)ϕ(n)为小于或等于n,并与n互质的整数的个数,比如6,比它小的和它互质 ...
- HDU 5597 GTW likes function(规律+欧拉函数模板题)——BestCoder Round #66(div.1 div.2)
GTW likes function Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Oth ...
- (hdu step 7.2.1)The Euler function(欧拉函数模板题——求phi[a]到phi[b]的和)
题目: The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDU 5597 GTW likes function
题意: 现在给出下列两个定义: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\ ...
- HDU 5597 GTW likes function 打表
GTW likes function 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5596 Description Now you are give ...
- hdoj GTW likes function 5597 (裸欧拉函数)
GTW likes function Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Oth ...
最新文章
- C++ 笔记(25)— 理解 C++ 中的头文件和源文件的作用
- 小功率荧光灯拆解分析
- 扇出性 java_索引与算法
- 算法笔记(JavaScript版)——排序
- spring-6、动态代理(cglib 与 JDK)
- 我们应该搞清楚分支预测
- LeetCode MySQL 180. 连续出现的数字(cast)
- 徐汉字java字符_汉字徐的拼音部首-汉字徐的笔画和解释-汉字徐在线查新华字典...
- Easy Recovery帮你解决数据丢失的苦恼
- 【转】细说@Html.ActionLink()的用法
- dw向右滚动字幕HTML,[转载]DW添加滚动字幕[转]
- python中没有严格意义上的私有成员_尔雅尔雅学习通APP家园的治理:环境科学概论题库及答案...
- python多边形的绘制教程_使用Python matplotlib绘制3D多边形
- Delphi XE2控件安装方法
- element-ui 图标太少解决方案
- linux如何永久获取root,Linux如何获取root权限?我只想到这些方法了,欢迎补充
- 虚拟机 Ubuntu 14.04 LTS (64 bits) 下安装 Kurento v6 并运行 kurento-hello-world
- Android 银行卡快捷支付
- Android组件安全
- NFT游戏开发元宇宙游戏开发游戏源码+搭建
热门文章
- 网络安全行业需要学历吗?需要考研吗?
- 安装MySQL5.7时卡在starting server。the configuration step starting server is taking longer than expected
- python运维必须会用的库
- java银行管理系统ui_java毕业设计_springboot框架的商业银行管理平台
- 官媒:发挥数字货币的正能量,服务于实体经济
- 【CAJ转PDF】利用CAJ云阅读将CAJ转换成PDF
- matplotlib画图自定义marker
- (Pycharm新版专业版)初次部署无法同步文件,报错信息:找不到要处理的文件或文件夹
- 数据库中 码、候选码、主码 的区别
- 图的十字链表存储法详解