摘要:
1 /* 2 先按右端点由小到大排序,相等的话左端点由大到小(否则会少算) 3 */ 4 #include <iostream> 5 #include <cstdlib> 6 #include <cstring> 7 using namespace std; 8 9 const int N = 10000;10 /**下面的不会用 11 typedef struct Node 12 {13 int a, b;14 bool operator < (const Node &node) const//此时使用sort排序 15 {16 return 阅读全文
posted @ 2013-04-13 20:28
加拿大小哥哥
阅读(523)
评论(0)
推荐(0)
摘要:
1 /*贪心可能导致无解; 2 硬币系统是10,7,5,1元,那么12元用贪心法得到的硬币数为3,而最少硬币数是2。 3 对于此题,可以举个例子: 4 若有1,5,7,10这四种货币,则易知 5 1=1 6 2=1+1 7 3=1+1+1 8 …… 9 6=5+110 那么推下去可知11 表示12这个面值需要的货币数,等于表示11或7或5或2需要的货币数+1。12 那么题中若要求表示12所需用的最小货币数,只需寻找表示11或7或5或2需要的货币数中的最小值。13 14 */15 16 //硬币数... 阅读全文
posted @ 2013-04-13 20:26
加拿大小哥哥
阅读(577)
评论(0)
推荐(2)
摘要:
1 /* 2 不是贪心,若是先按长排序在按宽,若是长很大宽很小 ,则若是后边款稍微大一些就不行了 3 */ 4 #include <stdio.h> 5 #include <iostream> 6 #include <cstring> 7 #include <algorithm> 8 using namespace std; 9 10 const int N = 1005;11 typedef struct Node12 {13 int a;14 int b;15 }Node;16 Node q[N];17 int n;18 int d[N];1 阅读全文
posted @ 2013-04-13 10:35
加拿大小哥哥
阅读(296)
评论(0)
推荐(2)