摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2093#include<cstdio>#include<cstdlib>#include<cstring>#defineMAX1000typedefstruct{charname[11];intsum;inttotal;}credit;intcmp(constvoid*a,constvoid*b){if((*(credit*)a).total!=(*(credit*)b).total)return(*(credit*)a).total-(*(credit*)b).total 阅读全文
posted @ 2011-05-07 22:51 yansirfuture 阅读(231) 评论(0) 推荐(0)
摘要: 先对田忌和国王的马进行排序,我是从大到小排序的。 贪心的策略: 一、当田忌最快的马比国王最快的马快时,用田忌最快的马赢国王最快的马。 二、当田忌最快的马比国王最快的马慢时,用田忌最慢的马输给国王最快的马。三、当田忌最快的马跟国王最快的马一样快时,分情况。 证明一、:假设现在国王最快的马是K,田忌最快的马是T,如果存在一种更优的比赛策略,让T的对手不是K,而使得田忌赢更多的钱的话,那么设此时K的对手是t,T的对手是k:( T>K &&T>t && K>k)1、 若t>K,则有T>k,t>K。这个结果和T>K,t>k是 阅读全文
posted @ 2011-05-07 19:48 yansirfuture 阅读(3224) 评论(3) 推荐(2)
摘要: 最近杭电的数据很阴险了,FatMouse' Trade,没过的同学测这组数据:03100010001000Answer300.0001#include<iostream>2#include<algorithm>3#include<stdio.h>4usingnamespacestd;5structnode6{7intj,f;8doublea;9};1011nodetest[1005];12boolcomp(nodea1,nodea2)13{14if(a1.a!=a2.a)15returna1.a>a2.a;16else17return0;18} 阅读全文
posted @ 2011-05-07 14:22 yansirfuture 阅读(199) 评论(0) 推荐(0)
摘要: 这几天做ACM Step,比较不错,在做一道题的时候,我用的是string,函数用的是strncmp,说参数不匹配,看了看函数原型,参数是const char *,而我用的是string,需要转换一下:http://acm.hdu.edu.cn/showproblem.php?pid=2629#include<iostream>usingnamespacestd;intmain(){intn,i,temp;chars[50];stringregional[8]={"Zhejiang","Beijing","Taiwan", 阅读全文
posted @ 2011-05-07 11:52 yansirfuture 阅读(389) 评论(0) 推荐(0)