http://acm.hdu.edu.cn/showproblem.php?pid=4282

题解:http://www.cnblogs.com/E-star/archive/2012/09/11/2680992.html

View Code

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>#define CL(a,num) memset((a),(num),sizeof(a))
#define iabs(x)  ((x) > 0 ? (x) : -(x))
#define Min(a,b) (a) > (b)? (b):(a)
#define Max(a,b) (a) > (b)? (a):(b)#define ll __int64#define MOD 100000007
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)
#define test puts("<------------------->")
#define maxn 100007
#define M 100007
#define N 107
using namespace std;
//freopen("din.txt","r",stdin);

ll inf = 2147483648ll;ll Pow(int a,int b){ll sum = 1;for (int i = 1; i <= b; ++i) sum *= a;return sum;
}
bool Bsearch(int L,int R,int x,int z,int k,ll POW){int l = L, r = R;while (l <= r){int m = (l + r)>>1;ll tmp = POW + Pow(m,z) + (ll)x*m*z;if (tmp < 0) r = m  -1;//注意这里处理ll溢出时的操作wa好几次else if (tmp == k) return  true;else if (tmp < k) l = m + 1;else r = m - 1;}return false;
}
int main(){//freopen("din.txt","r",stdin);int K;while (~scanf("%d",&K)){if (!K) break;int ans = 0;for (int x = 1; x < 50000 && x < K; ++x){//枚举xfor (int z = 2; z < 31; ++z){//枚举Zll tmp = Pow(x,z);if (tmp > K) break;int mk = Bsearch(x + 1,50000,x,z,K,tmp);//二分查找是否存在满足的y值if (mk) ans++;}}printf("%d\n",ans);}
}

转载于:https://www.cnblogs.com/E-star/archive/2012/09/11/2680966.html

HDU 4282 A very hard mathematic problem 二分题目相关推荐

  1. hdu 2058 解题报告 - The sum problem

    hdu 2058 解题报告 - The sum problem 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2058 等差求和公式: Sn=(a1+aN ...

  2. HDU 1036 Average is not Fast Enough!:题目解答源码

    2019独角兽企业重金招聘Python工程师标准>>> HDU 1036 Average is not Fast Enough!:题目解答源码 A relay is a race f ...

  3. 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) 给我们这个等式让我们找出这里面有多少 ...

  4. hdu 4430 Yukari's Birthday (简单数学 + 二分)

    Problem - 4430 题意是,给出蜡烛的数量,要求求出r和k,r是蜡烛的层数,k是每一层蜡烛数目的底数. 开始的时候,没有看清题目,其实中间的那根蜡烛是可放可不放的.假设放置中间的那根蜡烛,就 ...

  5. HDU - 6621 K-th Closest Distance——主席树+二分

    [题目描述] HDU - 6621 K-th Closest Distance [题目分析] 因为看到第kkk大的要求,刚开始的时候一直都在想怎么运用第kkk大来解决问题,但是后来看其他人的博客才发现 ...

  6. HDU - 6278 Just $h$-index主席树+二分

    HDU - 6278 Just hhh-index [题目描述] [题目分析] 题目要求在区间[l,r][l,r][l,r]内大于h的数不少于h个,对于这种最大化问题,我们应该想到二分. 最小情况显然 ...

  7. hdu 1054 Strategic Game 最小点覆盖 = 最大二分匹配

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1054 简单二分匹配,根据题意构造一个无向图.然后求最小点覆盖,然后扫描mark数组将曾经匹配的点所匹配 ...

  8. hdu 2141 Can you find it(二分)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2141 题意:给出三个数列a,b,c和一组数x,求对于每个x是否存在 ai + bj + ck = x;其中 ...

  9. HDU 5664 Lady CA and the graph 二分,树分治

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5664 题意:有一个有n个点的树(2<=n<=50,000),链(a,b)被称作折链,当且仅 ...

最新文章

  1. 从一线撤回二三线城市的程序员们,最后都怎么样了?
  2. 详解Linux Initrd
  3. oracle10g 学习 方向DBA三
  4. 怎么下载正版am_新买的笔记本电脑如何重装自带的正版Office学生版
  5. 什么是Ext(ExtJs)【转载】
  6. 新东方java开发待遇_新东方教师薪酬与考核曝光!拿去即用(仅供参考)
  7. 专题:CentOS社区企业操作系统
  8. android动画的实现过程
  9. 9.TCP/IP 详解卷1 --- IP 选路
  10. 分享最新36款高质量免费英文字体
  11. php 微信公众号客服,微信公众平台开发多客服
  12. 基于生物特征密钥生成研究 ------应用于区块链领域密钥的生成办法
  13. 音视频学习(三)——sip协议
  14. 网络工程师(中级)知识点记录
  15. 【Scrum】借由数个冲刺,实现产品的敏捷开发!
  16. python英语单词 扇贝英语安卓下载_扇贝单词英语版手机版|扇贝单词英语版安卓版下载 v3.6.402 - 跑跑车安卓网...
  17. 第四章:经典量化策略集锦(第八篇:CAPM模型的应用 )
  18. 2020家用千兆路由器哪款好_家用路由器哪个牌子好穿墙2020
  19. 使用 teredo 穿透NAT访问 ipv6
  20. 【JS】V8 引擎原理

热门文章

  1. Linux浏览文件的常用命令
  2. Windows安装MySQL 5.5完整步骤图解
  3. Struts2框架完成登录操作案例
  4. Java加视频特效,实现伪原创
  5. html制作手机预览效果,新移动端Html5方式预览报表插件
  6. win8.1计算机开启远程桌面连接不上,启动Win8.1远程桌面不得不知的方案
  7. noip 2017棋盘
  8. php配置文件能直接用吗,我应该在PHP应用程序中使用YAML配置文件吗?
  9. jira图片_JIRA使用不求人-从菜鸟到高手
  10. 父亲节python代码_python 计算 父亲节