Flyer(二分 HDU4768)】的更多相关文章

Flyer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2009 Accepted Submission(s): 736 Problem Description The new semester begins! Different kinds of student societies are all trying to advertise…
传送门 Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1718    Accepted Submission(s): 622 Problem Description The new semester begins! Different kinds of student societies are all trying to…
思路:由于最多只有一个是奇数,所以二分枚举这个点,每次判断这个点的左边区间段所有点的和作为 二分的依据. 代码如下: #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<set> #include<vector> #define ll long long #define M 20…
题目链接: 传送门 Flyer Time Limit: 1000MS     Memory Limit: 32768 K Description The new semester begins! Different kinds of student societies are all trying to advertise themselves, by giving flyers to the students for introducing the society. However, due…
Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 386    Accepted Submission(s): 127 Problem Description The new semester begins! Different kinds of student societies are all trying to adver…
<题目链接> <转载于  >>> > 题目链接: n个社团派发传单,有a,b,c三个参数,派发的规则是,派发给序号为a,a+c....a+k*c,序号要求是小于等于b 这其中,有一个学生只收到了奇数传单,要求找出这个学生的编号与得到的传单数目 . 解题分析: 用二分来划分区间,如果左区间传单之和为奇数,则那个学生在左区间,否则在右区间,由于每个社团的区间内得到传单的学生为等差数列,所以可以很容易得到枚举的区间内的传单数. #include <cstdio&g…
/* 如果发的传单是偶数,那么所有人都收到双数张. 仅考虑发了单数张传单,二分答案x,如果x左边是偶数,那么答案在右侧,如果x左边是奇数,那么答案在左侧 */ #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define ll long long #define maxn 20005 #define INF 1000000009 using namespac…
http://acm.hdu.edu.cn/showproblem.php?pid=4768 题意:n个传单分别发给编号为ai, ai + ci, ai + 2 * ci, .. , ai + k * ci的学生,其中k 是满足 ai + k * ci <= bi 的最大的k,题目保证收到传单的个数为奇数的学生最多只有一个,求这个学生的编号和收到的传单数. 方法:考虑前i个学生,sum[i]表示前i个学生收到传单的个数的奇偶性,如果sum[i]为奇数,证明那个学生一定在前i个,否则在i之后,据此…
题意:       n个社团给同学发传单,同学一共有1--2^31这么多,每个社团有三个数A ,B ,C ,只有 满足 A ,A + C ,A + C + C ...A + KC <= B 的学生才能得到传单,问你谁收到的传单数是奇数,题目保证给的测试数据要么没有奇数的,要么只有一个是奇数个传单. 思路:      "题目保证给的测试数据要么没有奇数的,要么只有一个是奇数个传单." ,这句非常关键,我们二分枚举1--2^31,对于mid,算出0--mid一共发出去tmp张传单,如…
二分.... Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 722    Accepted Submission(s): 245 Problem Description The new semester begins! Different kinds of student societies are all trying t…
hdu4768:http://acm.hdu.edu.cn/showproblem.php?pid=4768 题意:给你1--2^32个位置,然后有m个操作,每次操作给你3个数 a,b,c,然后在a,a+c,a+2*c......a+k*c的位置加一,其中a+k*c<=b,a+(k+1)*c>b,要你找出最后的结果是奇数的位置和这个数. 题解:由于这一题,题目保证最多只有一个奇数,所以可以想到用二分.具体的方法可以直接看代码. #include<iostream> #include…
题目: Flyer 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4768 分析:二分.只需要注意到最多只有一个为奇数,则可以首先求出学生获得的总的传单数,为奇数时,二分找到答案. #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<algorithm> using namespace std;…
Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2795    Accepted Submission(s): 1051 Problem Description The new semester begins! Different kinds of student societies are all trying to adv…
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 8748  Solved: 3835[Submit][Status][Discuss] Description 现在请求你维护一个数列,要求提供以下两种操作:1. 查询操作.语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度.2. 插入操作.语法:A n 功能:将n加上t,其中t是最近一次查询…
2756: [SCOI2012]奇怪的游戏 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 3352  Solved: 919[Submit][Status][Discuss] Description Blinker最近喜欢上一个奇怪的游戏. 这个游戏在一个 N*M 的棋盘上玩,每个格子有一个数.每次 Blinker 会选择两个相邻的格子,并使这两个数都加上 1. 现在 Blinker 想知道最少多少次能使棋盘上的数都变成同一个数,如果永远不能变成…
POJ 2104 K-th Number 时空隧道 题意: 给出一个序列,每次查询区间第k小 分析: 整体二分入门题? 代码: #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> //by NeighThorn #define inf 0x3f3f3f3f using namespace std; +,maxm=+; int n,m,a[maxn],ans[max…
Description 一个长度为n的序列a,设其排过序之后为b,其中位数定义为b[n/2],其中a,b从0开始标号,除法取下整. 给你一个长度为n的序列s. 回答Q个这样的询问:s的左端点在[a,b]之间,右端点在[c,d]之间的子序列中,最大的中位数. 其中a<b<c<d. 位置也从0开始标号. 我会使用一些方式强制你在线. Input 第一行序列长度n. 接下来n行按顺序给出a中的数. 接下来一行Q. 然后Q行每行a,b,c,d,我们令上个询问的答案是x(如果这是第一个询问则x=0…
Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floating point. You may assume k is always valid, that is: k ≤ total nodes. You are guaranteed to have onl…
Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floating point. You are guaranteed to have only one unique value in the BST that is closest to the target.…
第一种:顺序查找法 中心思想:和数组中的值逐个比对! /* * 参数说明: * array:传入数组 * findVal:传入需要查找的数 */ function Orderseach(array,findVal){ var temp = false; //控制开关 for(var i =0;i<array.length;i++){ if(array[i] == findVal){ //逐个匹配是否相等 temp = true; //如果找到,temp设置为true; return i; //返…
1305: [CQOI2009]dance跳舞 Description 一次舞会有n个男孩和n个女孩.每首曲子开始时,所有男孩和女孩恰好配成n对跳交谊舞.每个男孩都不会和同一个女孩跳两首(或更多)舞曲.有一些男孩女孩相互喜欢,而其他相互不喜欢(不会“单向喜欢”).每个男孩最多只愿意和k个不喜欢的女孩跳舞,而每个女孩也最多只愿意和k个不喜欢的男孩跳舞.给出每对男孩女孩是否相互喜欢的信息,舞会最多能有几首舞曲? Input 第一行包含两个整数n和k.以下n行每行包含n个字符,其中第i行第j个字符为'…
[题目分析] 整体二分显而易见. 自己YY了一下用树状数组区间修改,区间查询的操作. 又因为一个字母调了一下午. 貌似树状数组并不需要清空,可以用一个指针来维护,可以少一个log 懒得写了. [代码] #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 50005 #define inf…
Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2229    Accepted Submission(s): 252 Problem Description The shorter, the simpler. With this problem, you should be convinced of this truth.    Y…
题目链接 XOR 游戏 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 256    Accepted Submission(s): 86 Problem Description众所周知,度度熊喜欢XOR运算[(XOR百科)](http://baike.baidu.com/view/674171.htm). 今天,它发明了一种XOR新游戏…
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t m…
来到机房刷了一道水(bian’tai)题.题目思想非常简单易懂(我的做法实际上参考了Evensgn 范学长,在此多谢范学长了) 题目摆上: 1044: [HAOI2008]木棍分割 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3162  Solved: 1182[Submit][Status][Discuss] Description 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, 总共有n-1个连接处. 现在允许你最多砍断m个…
1014: [JSOI2008]火星人prefix Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 6243  Solved: 2007[Submit][Status][Discuss] Description 火星人最近研究了一种操作:求一个字串两个后缀的公共前缀.比方说,有这样一个字符串:madamimadam,我们将这个字符串的各个字符予以标号:序号: 1 2 3 4 5 6 7 8 9 10 11 字符 m a d a m i m a d…
3130: [Sdoi2013]费用流 Time Limit: 10 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 960  Solved: 505[Submit][Status][Discuss] Description Alice和Bob在图论课程上学习了最大流和最小费用最大流的相关知识.    最大流问题:给定一张有向图表示运输网络,一个源点S和一个汇点T,每条边都有最大流量.一个合法的网络流方案必须满足:(1)每条边的实际流量都不超…
题目描述 国防部计划用无线网络连接若干个边防哨所.2 种不同的通讯技术用来搭建无线网络: 每个边防哨所都要配备无线电收发器:有一些哨所还可以增配卫星电话. 任意两个配备了一条卫星电话线路的哨所(两边都ᤕ有卫星电话)均可以通话,无论 他们相距多远.而只通过无线电收发器通话的哨所之间的距离不能超过 D,这是受收发器 的功率限制.收发器的功率越高,通话距离 D 会更远,但同时价格也会更贵. 收发器需要统一购买和安装,所以全部哨所只能选择安装一种型号的收发器.换句话 说,每一对哨所之间的通话距离都是同一…
题目背景 在艾泽拉斯大陆上有一位名叫歪嘴哦的神奇术士,他是部落的中坚力量 有一天他醒来后发现自己居然到了联盟的主城暴风城 在被众多联盟的士兵攻击后,他决定逃回自己的家乡奥格瑞玛 题目描述 在艾泽拉斯,有n个城市.编号为1,2,3,...,n. 城市之间有m条双向的公路,连接着两个城市,从某个城市到另一个城市,会遭到联盟的攻击,进而损失一定的血量. 没经过一个城市,都会被收取一定的过路费(包括起点和终点).路上并没有收费站. 假设1为暴风城,n为奥格瑞玛,而他的血量最多为b,出发时他的血量是满的.…