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,用线段树维护区间最大值, ...
随机推荐
- 吴裕雄 python oracle子查询的用法(3)
import cx_Oracle conn = cx_Oracle.connect("scott/admin@localhost:1521/orcl")cursor = conn. ...
- ROC,AUC,Precision,Recall,F1的介绍与计算(转)
1. 基本概念 1.1 ROC与AUC ROC曲线和AUC常被用来评价一个二值分类器(binary classifier)的优劣,ROC曲线称为受试者工作特征曲线 (receiver operatin ...
- 获取url后面的参数的方法
1. function GetRequest() { var url = 'http://wwww.jb51.net/?q=js'; //获取url中"?"符后的字串 if (ur ...
- 四、Factory Method 工厂方法模式
需求:对象的创建由工厂统一创建,会使用到模板模式 代码清单: 工厂: public abstract class Factory { public abstract Product createPro ...
- stock抓取基本资料
use Goutte\Client; use GuzzleHttp\Client as GuzzleClient; include './vendor/autoload.php'; $client = ...
- SpringBoot配置logback
1.在SpringBoot中已经集成了logback.在pom.xml中加入以下spring-boot-starter依赖,使用默认版本即可: <dependency> <group ...
- SpringCloud报错:com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
启动SpringCloudEureka 报错:com.netflix.discovery.shared.transport.TransportException: Cannot execute req ...
- error LNK2019: 无法解析的外部符号 "class std::basic_ostream<char,struct std::char_traits<char> >
1,VS2013: 错误 1 error LNK2019: 无法解析的外部符号 "class std::basic_ostream<char,struct std::char_trai ...
- 什么是PCM?它和.wav文件是什么关系?
PCM(Pulse Code Modulation----脉码调制录音).所谓PCM录音就是将声音等模拟信号变成符号化的脉冲列,再予以记录.PCM信号是由[1].[0]等符号构成的数字信号,而未经过任 ...
- 转移动APP测试实践
http://blog.csdn.net/hgstclyh/article/details/53115325