hdu 5491(2015合肥网赛)The Next
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5491
题意就是,T组测试数据。然后L,S1,S2。L的二进制中有x个1,x满足 S1<=x<=S2
求满足S1<=x<=S2
直接暴力,但是有个地方要注意,当L在递增枚举的过程中,X小于S1的时候,将其二进制中S1-X个0位转化成1,不然会超时
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
ll t,ans=,a[],n,s1,s2;
ll i,sum;
scanf("%I64d",&t);
while (t--)
{
scanf("%I64d %I64d %I64d",&n,&s1,&s2);
int flag=;
while ()
{
n++;
ll e=n;
i=,sum=;
while (e)
{
a[++i]=e%;
if (e%) sum++;
e/=;
}
if (sum<s1)
{
ll q=s1-sum,j,w=;
for (j=;j<=i;j++)
{
if (!a[j])
{
a[j]=;
w++;
}
if (w==q) break;
}
break;
}
if (sum<=s2&&sum>=s1)
{
flag=;
break;
}
}
printf("Case #%I64d: ",ans++);
if (flag==) printf("%I64d\n",n);
else
{
sum=;ll x=;
for (ll j=;j<=i;j++)
{
sum+=x*a[j];
x*=;
}
printf("%I64d\n",sum);
}
}
return ;
}
hdu 5491(2015合肥网赛)The Next的更多相关文章
- hdu 5493 (2015合肥网赛) Queue
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5493 题目大意,t组数据,n个人,n行每行分别是人的身高和这个人的左边或右边比他高的人的个数,输出符合条件 ...
- hdu 5475(2015上海网赛) An easy problem
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5475 题意就是给X赋初值1,然后给Q个操作,每个操作对应一个整数M:如果操作是1则将X乘以对应的M,如果是 ...
- hdu 5455 (2015沈阳网赛 简单题) Fang Fang
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5455 题意就是找出所给字符串有多少个满足题目所给条件的子串,重复的也算,坑点是如果有c,f以外的字符也是不 ...
- hdu 5461(2015沈阳网赛 简单暴力) Largest Point
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5461 题意就是在数组中找出a*t[i]*t[i]+b*t[j]的最大值,特别注意的是这里i和i不能相等,想 ...
- hdu 5459(2015沈阳网赛) Jesus Is Here
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5459 题意 给出一组字符串,每个字符串都是前两个字符串相加而成,求第n个字符串的c的各个坐标的差的和,结果 ...
- hdu 5443 (2015长春网赛G题 求区间最值)
求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 2 ...
- ACM学习历程—HDU5490 Simple Matrix (数学 && 逆元 && 快速幂) (2015合肥网赛07)
Problem Description As we know, sequence in the form of an=a1+(n−1)d is called arithmetic progressio ...
- hdu 5441 Travel (2015长春网赛)
http://acm.hdu.edu.cn/showproblem.php?pid=5441 题目大意是给一个n个城市(点)m条路线(边)的双向的路线图,每条路线有时间值(带权图),然后q个询问,每个 ...
- 2015合肥网络赛 HDU 5489 Removed Interval LIS+线段树(树状数组)
HDU 5489 Removed Interval 题意: 求序列中切掉连续的L长度后的最长上升序列 思路: 从前到后求一遍LIS,从后往前求一遍LDS,然后枚举切开的位置i,用线段树维护区间最大值, ...
随机推荐
- Android-Anim-Playground
Android-Anim-Playground Latest animation ideas I developed to make apps more attractive. Why having ...
- atrous convolution
atrous convolution 简而言之,带孔卷积: 来自:https://zhuanlan.zhihu.com/p/27470685 假设一个二维信号,每个位置对应的输出为和卷积核为,带孔卷积 ...
- Centos 7升级内核
检查当前 CentOS 系统内核版本 uname -sr 在 CentOS 7 上启用 ELRepo 仓库 rpm --import https://www.elrepo.org/RPM-GPG-KE ...
- vue样式绑定
vue 绑定class 和style 有相同的地方,可以是数组和对象,对于class class是真实的在css样式中添加的,只不过在元素中添加需要:class这样代表绑定,然后这个class作为对象 ...
- 运用active和hover实现导航栏的页面切换
.nav ul li a:hover{ background: #3E6EDD;}.nav ul li a:hover img{ display: block;}.nav ul li a.active ...
- MATLAB GUI图片添加背景
global im [filename,pathname]=uigetfile('*.jpg','输入图片'); file=strcat(pathname,filename); im=imread(f ...
- pip安装插件库
升级:python -m pip install --upgrade pip 读excel:pip install xlrd 写入excel:pip install xlwt
- 自定义sql server 聚合涵数
using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Micr ...
- metasploit framework(十一):获取漏洞信息
查看参数 这个模块运行需要一个session 所以需要先获取到一个session 就获得了一个session 再回到枚举补丁模块 添加session 查看参数看到session已经添加上去了 run ...
- Python 面向对象基础(类、实例、方法、属性封装)
python是面向对象语言,一切皆对象. 面向过程: 变量和函数. “散落” 在文件的各个位置,甚至是不同文件中.看不出变量与函数的相关性,非常不利于维护,设计模式不清晰. 经常导致程序员,忘记某个变 ...