P1097合并果子
Accepted
标签:贪心NOIP提高组2004
描述
在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆。多多决定把所有的果子合成一堆。 
每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和。可以看出,所有的果子经过n-1次合并之后,就只剩下一堆了。...
                            
                            
                                分类:
编程语言   时间:
2015-05-12 17:15:34   
                                阅读次数:
172
                             
                         
                    
                        
                            
                            
                                题目传送:Codeforces Round #301 (Div. 2)
A. Combination Lock
水题,求最小移动次数,简单贪心一下即可
AC代码:
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#inclu...
                            
                            
                                分类:
其他好文   时间:
2015-05-01 12:09:59   
                                阅读次数:
217
                             
                         
                    
                        
                            
                            
                                分析:简单贪心题,注意这里给出的已经是单价了,而不是物品的总价值,直接用来排序即可。
#include
#include
using namespace std;
struct A
{
	int p,m;
}a[105];
bool cmp(A a1,A a2)
{
	return a1.p<a2.p;
}
int main()
{
	int v,n,i;
	int sum;
	whil...
                            
                            
                                分类:
其他好文   时间:
2015-04-30 21:54:50   
                                阅读次数:
249
                             
                         
                    
                        
                            
                            
                                观察发现m1+m2变为2*sqrt(m1*m2)质量是能够减少的,
因此按质量从大到小排序,每次取最大质量的两个合并,减少的质量是最多的。
合并n-1次,最终得到的一个数就是结果。
这里用优先队列写的比较方便。
#include
#include
#include
using namespace std;
priority_queue q;
int main()
{
    int...
                            
                            
                                分类:
其他好文   时间:
2015-04-29 23:32:25   
                                阅读次数:
294
                             
                         
                    
                        
                            
                            
                                UVA - 108
Maximum Sum
Time Limit: 3000MS
 
Memory Limit: Unknown
 
64bit IO Format: %lld & %llu
Submit Status
Description
Background
A problem that is simple ...
                            
                            
                                分类:
其他好文   时间:
2015-04-03 09:25:36   
                                阅读次数:
210
                             
                         
                    
                        
                            
                            
                                The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you’ve got an array of n elements (the elements of the array are indexed starting from...
                            
                            
                                分类:
其他好文   时间:
2015-04-02 16:31:33   
                                阅读次数:
125
                             
                         
                    
                        
                            
                            
                                993 Product of digits
For a given non-negative integer number N, ?nd the minimal natural Q such that the product of all
digits of Q is equal N.
Input
The ?rst line of input contains one po...
                            
                            
                                分类:
其他好文   时间:
2015-04-02 09:11:13   
                                阅读次数:
219
                             
                         
                    
                        
                            
                            
                                UVA - 10700
Camel trading
Time Limit: 3000MS
 
Memory Limit: Unknown
 
64bit IO Format: %lld & %llu
Submit Status
Description
Problem E - Camel trading
Time L...
                            
                            
                                分类:
其他好文   时间:
2015-03-31 09:04:17   
                                阅读次数:
140
                             
                         
                    
                        
                            
                            
                                原题地址简单贪心首先,补提交卡应该连续使用,其次,补提交卡应该全部用掉(如果补提交卡多于未提交天数则额外处理)所以,依次遍历未提交日期,计算:从当前位置开始,用M张补提交卡覆盖后面连续M个数字,此时的连续提交天数。代码: 1 #include 2 3 using namespace std; 4.....
                            
                            
                                分类:
其他好文   时间:
2015-03-21 18:35:03   
                                阅读次数:
187
                             
                         
                    
                        
                            
                            
                                Saruman's Army
Time Limit: 1000MS
 
Memory Limit: 65536K
Total Submissions: 4699
 
Accepted: 2430
Description
Saruman the White must lead his army along a straight path...
                            
                            
                                分类:
编程语言   时间:
2015-03-14 15:25:18   
                                阅读次数:
211