贪心算法
文章平均质量分 69
id_zhouyfei
始于颜值 陷于才华 忠于人品
展开
-
题目106 背包问题
已AC代码: #include #include using namespace std; struct Things { int v; int w; }t[15]; bool compare(const Things a, const Things b) { return a.v > b.v; } int main() { int n;原创 2016-07-28 10:08:33 · 316 阅读 · 0 评论 -
题目14 会场安排问题
已AC代码: #include #include using namespace std; struct Things { int s; int f; }t[10005]; bool compare(const Things& a, const Things& b) { return a.f < b.f; } int main() { int m; sca原创 2016-07-28 10:17:28 · 257 阅读 · 0 评论 -
题目6 喷水装置(一)
已AC代码: #include #include using namespace std; bool compare(double x,double y) { return x*x>y*y; } int main() { int m; scanf("%d", &m); while(m--) { int n, cont=0, len=20;原创 2016-07-28 10:45:27 · 249 阅读 · 0 评论 -
题目71 独木舟上的旅行
已AC代码: #include #include using namespace std; int main() { int t; scanf("%d", &t); while(t--) { int w, n, cont; scanf("%d%d", &w, &n); int a[n]; cont=n原创 2016-07-28 10:52:41 · 357 阅读 · 0 评论 -
题目364 田忌赛马
#include #include using namespace std; int main() { int n; while((scanf("%d", &n)) != EOF) { int t[n], k[n]; int twin=0, kwin=0, pin=0; int tslow=0,kslow=0, tfast=n原创 2016-07-28 11:14:02 · 753 阅读 · 0 评论 -
重做题目6 喷水装置
已AC代码: #include #include #include using namespace std; bool compare(double x, double y) { return x*x>y*y; } int main() { int t; scanf("%d", &t); while(t--) { int n, cont=0原创 2016-07-31 08:35:41 · 255 阅读 · 0 评论 -
题目448 寻找最大数
解题思路 :在可以删除的范围内(m+1)找到最大的数,删除它前面的,有两种情况:1、m为零了,n还没有遍历完,把剩余的全部放到临时数据里保存 2、数据已经遍历完了,m还不为零,就再从临时数组里面删除m个数。 已AC代码: #include #include using namespace std; int main() { int t; scanf("%d", &t)原创 2016-07-31 09:24:56 · 326 阅读 · 0 评论