2018 CCPC 女生赛 hdoj6288 缺失的数据范围
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6288
Summarize:
1、二分查找答案;
2、自带log函数精度不够,需自己写;
3、注意二分递归的左右区间;
4、计算中可能爆LL,故需尽可能做一步就判断一次;
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define LL long long LL T, a, b, k;
LL R = 1e18; LL log2(LL n)
{
for(int i=; i<=; i++)
if((LL)pow(2LL, i) >= n)
return i;
} bool judge(LL n)
{
LL x = n;
for(int i=; i<a; i++) {
if(x > k/n) return false;
x *= n;
} LL t = log2(n);
LL y = t;
for(int i=; i<b; i++) {
if(y>k || x>k/y) return false;
y *= t;
}
// cout<<"x,y: "<<x<<' '<<y<<endl; if(x > k/y)
return false;
return true;
} void half_find(LL l, LL r)
{
if(l == r) {
printf("%lld\n", l);
return;
}
LL mid = (l+r)/+1LL;
// cout<<"AA "<<l<<' '<<r<<' '<<mid<<endl;
if(judge(mid))
half_find(mid, r);
else
half_find(l, mid-);
} int main()
{
ios::sync_with_stdio(false);
scanf("%lld", &T);
while(T--)
{
scanf("%lld%lld%lld", &a, &b, &k);
half_find(, R);
} return ;
}
2018 CCPC 女生赛 hdoj6288 缺失的数据范围的更多相关文章
- 2018 CCPC 女生赛 hdoj6287 口算训练
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6287 Summarize: 1.分解质因数: 2.二分查找函数lower_bound与upper_bo ...
- 2018 CCPC网络赛
2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...
- 2019.ccpc女生赛-wfinal总结
2019ccpc女生赛离它结束有四天了,在这个期间我想了很多,想了想还是决定写这个总结.作为这个队伍唯一的一名大一队员,我很庆幸,能跟着两个学姐一起打比赛,计爱玲师姐,即将工作,张莹俐学姐.这估计都是 ...
- 【2018 CCPC网络赛 1004】Find Integer(勾股数+费马大定理)
Problem Description people in USSS love math very much, and there is a famous math problem . give yo ...
- 2018 CCPC 女生专场
可能是史上最弱的验题人—— Problem A (小)模拟. #include <bits/stdc++.h> using namespace std; int T; int main() ...
- 【2018 CCPC网络赛】1009 - 树
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6446 题目给出的数据为一棵树,dfs扫描每条边,假设去掉某条边,则左边 x 个点,右边 n-x 个点, ...
- 【2018 CCPC网络赛】1004 - 费马大定理&数学
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6441 Knowledge Point: 1. 费马大定理:当整数n >2时,关于x, y, z的 ...
- 2021 CCPC女生赛
newbie,A了五题铜牌收工 比赛时和队友悠哉游哉做题,想着干饭,最后幸好没滚出铜尾. 贴一下比赛过的代码 A题 签到 队友A的,判断正反方向序列是否符合要求 /*** * @Author: _Kr ...
- 2018 CCPC网络赛 几道数学题
1002 Congruence equation 题目链接 : http://acm.hdu.edu.cn/showproblem.php?pid=6439 题解 : https://www.zyb ...
随机推荐
- GCC在C语言中内嵌汇编 asm __volatile__
2012-11-26 22:20 17958人阅读 评论(2) 收藏 举报 分类: linux(59) 架构管理(24) C/C++(59) 目录(?)[+] 在内嵌汇编中,可以将C语言表达式 ...
- Bid和Ask
一直很懵到底哪个是哪个,记吧,很快就又懵了.网上又坑,每一个解释清楚的.这次搞明白了记下来. 当然,这么逗比的取名法我也是醉了.直接加点东西,UserBuy,UserSell,BankBuy,Bank ...
- 洛谷 - P1219 - 八皇后 - dfs
https://www.luogu.org/problemnew/show/P1219 一开始朴素检查对角线就TLE了,给对角线编码之后压缩了13倍时间? 找了很久的bug居然是&&写 ...
- FZU2277 Change(dfs序+树状数组)
传送门 题意 q次操作,操作有两种: 1 v x k:a[v]+=x,a[v']+=x-k(v'是v的子节点)... 2 v:查询\(a[v]mod(10^9+7)\) 分析 子节点增加的值为\(x+ ...
- python 基本类型的创建方法
1.int class int(object) | int(x=0) -> integer | int(x, base=10) -> integer | | Convert a numbe ...
- thinkphp5升级版开源框架tpframe v2.1发布
免费开源框架tpframe是一款以thinkphp5为驱动,在此基础上进行进一步的完善与改进的框架,保持了ThinkPHP5原有的所有特性,优化核心,减少依赖,为个人或企业建站提供高效.快速解决的方案 ...
- 拓扑排序复习——Chemist
一.基本算法 拓扑序列:对于一张有向图,求一个序列ai若对于每一条边(u,v),都满足au<=av ,则称这个序列为这张有向图的拓扑序列,一张图可能有多个拓扑序列. 求拓扑序列:找到入度为0的点 ...
- mac 配置nginx 虚拟域名(转载)
我是通过homebrew 安装nginx 的,所以安装目录是默认的,之前多个server都是放在默认安装目录下的nginx.conf里的,但是这样不太好,就是会导致nginx.conf 越来越长,而且 ...
- spring 通配符
原文地址:http://www.bubuko.com/infodetail-848675.html classpath是指 WEB-INF文件夹下的classes目录(惯例大于配置) classpat ...
- 一个Nice的生活主题博客模板
https://www.bitcron.com/ https://api.bitcron.com/ https://chopstack.com/