A very hard mathematic problem HDU - 4282(二分)
Haoren is very good at solving mathematic problems. Today he is working a problem like this:
Find three positive integers X, Y and Z (X < Y, Z > 1) that holds
X^Z + Y^Z + XYZ = K
where K is another given integer.
Here the operator “^” means power, e.g., 2^3 = 2 * 2 * 2.
Finding a solution is quite easy to Haoren. Now he wants to challenge more: What’s the total number of different solutions?
Surprisingly, he is unable to solve this one. It seems that it’s really a very hard mathematic problem.
Now, it’s your turn.
Input
There are multiple test cases.
For each case, there is only one integer K (0 < K < 2^31) in a line.
K = 0 implies the end of input.
Output
Output the total number of solutions in a line for each test case.
Sample Input
9
53
6
0
Sample Output
1
1
0
Hint
9 = 1^2 + 2^2 + 1 * 2 * 2
53 = 2^3 + 3^3 + 2 * 3 * 3
题意:
有多少个x,y,zx,y,zx,y,z满足 xz + yz + xyzxyzxyz = kkk
思路:
kkk < 231
1 ≤ x ≤ y ,z ≥ 2
那么易得 zzz ≤ 31
于是可以枚举z,然后等式两边开z次方根。得到一个大于x,y的边界值
再枚举x,此时x,z,k都是已知的,就可以二分y判断是否存在这一一个y。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>using namespace std;typedef long long ll;
ll k;ll Pow(ll a,ll b)
{ll res = 1;for(ll i = 1;i <= b;i++){res *= a;}return res;
}ll cal(ll x,ll y,ll z)
{return Pow(x,z) + Pow(y,z) + x * y * z - k;
}bool judge(ll x,ll maxy,ll z)
{ll l = x + 1,r = maxy;while(l <= r){ll mid = (l + r) >> 1;ll tmp = cal(x,mid,z);if(tmp == 0)return true;else if(tmp < 0){l = mid + 1;}else{r = mid - 1;}}return false;
}int main()
{while(~scanf("%lld",&k) && k){int ans = 0;for(ll z = 2;z <= 31;z++){ll maxy = pow(k,1.0/z);for(ll x = 1;x <= maxy;x++){if(judge(x,maxy,z))ans++;}}printf("%d\n",ans);}return 0;
}
A very hard mathematic problem HDU - 4282(二分)相关推荐
- HDU-4282 A very hard mathematic problem 技巧枚举+二分
题意 xz+yz+x∗y∗z=kx^z+y^z+x*y*z = k ( y>x&&z>1y>x&&z>1) 给我们这个等式让我们找出这里面有多少 ...
- HDU 2389(二分最大匹配优化算法,Hopcroft-Carp)
HDU 2389(二分最大匹配优化算法,Hopcroft-Carp) 题目链接: 大致题意; 您能帮助客人在下雨之前尽可能多地找到一把雨伞? 给定所有客人的位置和跑步速度,雨伞位置,到下雨开始时的时间 ...
- HDU 4282 A very hard mathematic problem 二分题目
http://acm.hdu.edu.cn/showproblem.php?pid=4282 题解:http://www.cnblogs.com/E-star/archive/2012/09/11/2 ...
- HDU - 5008 Boring String Problem(后缀数组+二分)
题目链接:点击查看 题目大意:给出一个字符串,接下来给出 q 个询问,每次询问字符串中第 k 大的子串,要求输出该字串的左右端点,如果有多个答案,输出左端点最小的一个 题目分析:因为在求出后缀数组后, ...
- hdu 5248(二分+贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5248 解题思路:这道题我原本的思路是动态规划,结果看到数很大,结果放弃了.然后想到二分,思路是对的,只 ...
- hdu 3622 二分+2-sat
/* 二分+2-sat 题意:在一个二维平面上给你n个炸弹,和2*n个位置,每一行的两个位置仅仅能有一个放炸弹 如今炸弹爆炸有一个半径.当炸弹爆炸时两个炸弹的半径化成的圆不能相交,求最大半径 二分半径 ...
- hdu 4033 二分几何
参考:http://blog.csdn.net/libin56842/article/details/26618129 题意:给一个正多边形内点到其他顶点的距离(逆时针给出),求正多边形的边长 二分多 ...
- hdu 4004 二分查找
直接二分查找答案即可,我的判断函数没有像大牛们那样优化,但是过是没问题的~ /* * hdu4004/linux.cpp * Created on: 2011-9-4 * Author : ben*/ ...
- hdu 5265(二分+枚举)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5265 解题思路: 首先对每个数进行去模,这样得到的数就会是[0,p-1]的范围,接下来就是如何组合的问 ...
- hdu 3264(二分+圆相交面积)
题意:给出一些圆,选择其中一个圆的圆心为圆心,然后画一个大圆,要求大圆最少覆盖每个圆的一半面积.求最小面积. 解题思路:首先枚举每个圆,以其圆心作为大圆的圆心,然后再用二分去寻找最小的半径. #inc ...
最新文章
- 康复治疗学可以考计算机吗,【大揭秘】2018“人机对话”康复医学治疗技术专业技术资格考试...
- linux shell脚本字符串连接符,学习Linux shell脚本中连接字符串的方法
- 您没有权限来打开应用程序_苹果建议:除非应用程序无响应,否则不要滑动强制退出...
- angr学习笔记(7)(malloc地址单元符号化)
- mysql having in_MySQL having子句
- php+tp框架+API,【路由】利用Thinkphp路由实现API开发版本管理
- JQuery实现广告效果(滚动切换)
- JVM笔记(一)数字在JVM中的表示
- 新入职了一个卷王,天天加班12点!张口闭口就是性能优化,太让人崩溃……...
- java 对象和类
- 百度之星资格赛1003:度度熊与邪恶大魔王
- MFC多国语言——资源副本
- 2021音视频技术大会北京站开幕
- 图像坐标球面投影_OpenLayers中的球面墨卡托投影
- 白话空间统计二十三回归分析番外:残差可视化
- Modelsim搭建只有driver的UVM验证平台
- 微型投影仪第三篇——磕磕绊绊
- 如何注册公司邮箱?公司邮箱邮件这样写98%的人都爱看
- Poco访问mysql
- 显示服务器人数已满,明日之后服务器人数已满怎么办 排队解决方法
热门文章
- 十天征服单片机百度云_51单片机 郭天祥十天学会单片机教学视频
- 《别闹了,费曼先生》
- 使用代码调用Attachments(附件)
- ubuntu tftp服务器搭建
- 结构张量 matlab 图像,图像处理中 结构张量(structure tensor)
- 手游图片素材提取_游戏资源提取工具(ExtractData日本游戏看内涵图)V2.5.38.966官方版下载 - 下载吧...
- 互动快报读报软件159份全国主流大报倾情奉献读者
- 苹果手机软件升级密码_微软:将向安卓和苹果iOS平台推出杀毒软件Defender
- Chrome插件:中国天气预报与万年历
- pci-e串口卡linux 驱动下载,PCI/PCIe卡驱动