hdu 4803 贪心/思维题】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=4803 话说C++还卡精度么?  G++  AC  C++ WA 我自己的贪心策略错了 -- 就是尽量下键,然后上键,最后下键补全,可是例子都过不了..... 题解參考http://www.cnblogs.com/xuesu/p/3967704.html http://www.cnblogs.com/Canon-CSU/p/3451784.html http://blog.csdn.net/keshuai199…
Maximum Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1797    Accepted Submission(s): 842 Problem Description Steph is extremely obsessed with “sequence problems” that are usually see…
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 */ #include <cstdio> #include <algor…
题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN], b[MAXN]; int main(void) //UVA 11292 The Dragon of Loo…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 现场做这道题的时候,感觉是思维题.自己智商不够.不敢搞,想着队友智商好,他们搞吧.可是没出来这题...... 以后不论什么时候,都自信点....该想的还是好好自己想,这类题感觉就是先去找性质,然后一点点找规律,假设必要的话.自己提出一点猜想.然后假设自己举不出来反例,就临时觉得是正确的 下午搞了一下午.发现还是悲剧,晚上參考了两个题解 http://blog.csd…
/* 参看博客地址:http://blog.csdn.net/oceanlight/article/details/7857713 重点是取完最优的后剩余的rest=n%lcm+lcm;中性价比小的数目num<lcm/性价比小的体积,因为如果大于的话 肯定可以由性价比好的替换. 然后枚举.从体积大的开始枚举次数少. 注意64位 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #define ll…
A.GPA(HDU4802): 给你一些字符串对应的权重,求加权平均,如果是N,P不计入统计 GPA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1193    Accepted Submission(s): 743 Problem Description In college, a student may take several…
看似区间数据结构的一道题 题目描述 Bessie and her friends are playing a unique version of poker involving a deck with N (1 <= N <= 100,000) different ranks, conveniently numbered 1..N (a normal deck has N = 13). In this game, there is only one type of hand the cows…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5776 题目让你求是否有区间的和是m的倍数. 预处理前缀和,一旦有两个数模m的值相同,说明中间一部分连续子列可以组成m的倍数. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib>…
B - 贪心 基础 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse contai…
1067 Sort with Swap(0, i) (25 分)   Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may…
Ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 461    Accepted Submission(s): 273 Problem Description , otherwise the i-th box contains exactly one ball, the color of which is a[i], a posi…
题目描述 B君和G君聊天的时候想到了如下的问题. 给定自然数l和r ,选取2个整数x,y满足l <= x <= y <= r ,使得x|y最大. 其中|表示按位或,即C. C++. Java中的|运算. Input 包含至多10001组测试数据. 第一行有一个正整数,表示数据的组数. 接下来每一行表示一组数据,包含两个整数l,r. 保证 0 <= l <= r <= 10181018. Output 对于每组数据输出一行,表示最大的位或. 样例 Sample Input…
51nod 1563 坐标轴上的最大团 坐标轴上有n个点,每个点有一个权值.第i个点的坐标是 xi ,权值是 wi .现在对这些点建图.对于点对 (i,j) ,如果 |xi−xj|≥wi+wj ,那么就给第i个点和第j个点之间连一条边. 问建好的图中最大团有几个点. 样例解释: Input 单组测试数据. 第一行有一个整数n (1≤n≤200000),表示坐标轴上有n个点. 接下来n行,每一行有两个整数xi, wi (0≤xi≤10^9,1≤wi≤10^9),表示第i个点的坐标和权值. 所有的x…
尽可能的让当前的平均值接近最后的平均值才能最快达到终点的情况 #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { // freopen("a.in" , "r" , stdin); int x , y; ) { if(y<x){ puts("-1"); continue; }…
D. Make a Permutation! time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n. Recently Ivan learned abo…
题目链接 TAG: 这是我近期做过最棒的一道贪心思维题,不容易想到,想到就出乎意料. 题意:给定两个含有N个正整数的数组a和b,让你输出一个数字k ,要求k不大于n/2+1,并且输出k个整数,范围为1~n的不重复数字, 要求这k个数字为下标的对应a和b中的数的和乘以2的值  分别大于a和b 的数组总和. 思路:首先对a进行降序排序,然后输出最大值的下标,随后进行幅度为2的枚举,对排序后的a2~an进行选择性输出下标,(注意,排序的时候用一个新数组开两个变量,一个index,一个v进行排序,可以用…
思维题,好题 把每条边的边权平分到这条边的两个顶点上,之后就是个sb贪心了 正确性证明: 如果一条边的两个顶点被一个人选了,一整条边的贡献就凑齐了 如果分别被两个人选了,一作差就抵消了,相当于谁都没有 代码 #include <bits/stdc++.h> #define rep(i,x,y) for(i=(x);i<=(y);++i) using namespace std; double a[10010]; int main(){ int n,m,i,x,y,z; double an…
HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There will be a special integer among t…
暑假杭电多校第一场,这一场是贪心场,很多贪心的题目,但是自己太菜,姿势挫死了,把自己都写吐了... 2018 Multi-University Training Contest 1 HDU6298.Maximum Multiple 题目意思就是给你一个n,找出来三个数x,y,z, 使得n=x+y+z,而且x,y,z都是n的因数,并且x*y*z为最大值,让你输出来x*y*z的最大值.如果没有满足条件的情况就输出-1. 由1=1/2+1/3+1/6=1/3+1/3+1/3=1/2+1/4+1/4,所…
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u011328934/article/details/26005267 题目链接:hdu 4803 Poor Warehouse Keeper 题目大意:有以个屏幕能够显示两个值,一个是数量x,一个是总价y. 有两种操作.一种是加一次总价,变成x,x+y:一种是加一个数量,这要的话总价也会对应加上一个的价钱.变成x+1.y+y/x.总价显示的为取整后的整数,小数部分忽略. 给定一个目标x.y.初始状…
PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数学题--你会你就能做,不会做就是真的做不出来QAQ 鲁迅曾说:一入数学深似海,从此AC是路人. 一些会说到的题目:(都是洛谷编号) 这些题目全都是原来NOIP考过的真题喔 1010 1014 1029 1035 1045 1075 1012 1351 2119 ok咱们开始说 第一题,洛谷P1010…
Allowance Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4903 Accepted: 1943 Description As a reward for record milk production, Farmer John has decided to start paying Bessie the cow a small weekly allowance. FJ has a set of coins in N (…
pid=5325">http://acm.hdu.edu.cn/showproblem.php? pid=5325 Problem Description Bobo has a tree,whose vertices are conveniently labeled by 1,2,...,n.Each node has a weight wi. All the weights are distrinct. A set with m nodes v1,v2,...,vm is a Bobo…
Online Judge:UVA12235 Label:思维题,状态定义,状压Dp 题面: 题目描述 有一个书架,上面放了n本书,从左往右的第i本书的高度为h[i].定义书架的混乱度为连续等高段的个数. 例如:{30,30,31,31,32}的混乱度为3:{30,32,32,31}的混乱度为3:{31,32,31,32,31}的混乱度为5. 现在你可以从中抽出至多k本书,然后将他们随意放回书架任意位置,求最终最小的混乱度. 对于100%的数据,N的范围[1,500],K的范围[1,100],书的…
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeForces - 215C - Crosses(思维题) C:CF–思维练习–CodeForces - 216C - Hiring Staff (思维+模拟) D:CF思维联系–CodeForces-217C C. Formurosa(这题鸽了) E:CF思维联系–CodeForces - 218C E…
C. Coffee Break 这个贪心之前好像写过,还是感觉挺难的,有点不会写. 这个题目大意是:给你一个数列n个元素,然后给你一天的时间,给你一个间隔时间d, 问你最少要用多少天可以把这个数列的所有元素放进去,注意元素之间必须相隔大于等于d,还有就是假设每一天之间的间隔大于d 解法: 借助队列来解题, 首先给这个元素按照元素大小来拍个序,贪心优先考虑小的,优先把小的放进去, 然后第一天肯定是要开一天的,如何后面的比这个大那就新开一天,否则就可以直接继承这一天. 这个就是解题思路,我觉得我应该…
题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考虑的). 只是需要判断总数的平均值 和 耗时最大的一道菜 哪个最大.. #include <iostream> #include <cstdio> #include <cstring> #include <cstring> #include <cmath&…
题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题,要注意超边界... #include <iostream> #include <cstring> #include <algorithm> using namespace std; <<); int n,m,x,y,a,b; int ok(int x1,int…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…