随笔分类 -  杂题

POJ 1328 Radar Installation 贪心
摘要:#include"stdio.h" #include"math.h" #include"stdlib.h" typedef struct { double x1,x2; }POINT; int cmp(const void *a,const void *b) { return (*(POINT *)a).x1>(*(POINT *)b).x1?1:-1; } POINT t[1000]; main() { int n,d,ans,i=0,j,judge,tag; double tx,ty; while(scanf... 阅读全文

posted @ 2012-02-28 20:58 andy_ 阅读(177) 评论(0) 推荐(0)

HDOJ 1052 Tian Ji -- The Horse Racing 贪心
摘要:田忌要以最小的代价赢和输对田忌和齐王的马从小到大各自排序,然后以田忌的马从两边对齐王的扫描,如果小的能赢,就赢,如果不能赢,就比两方最大的马,如果能赢则赢,如果也不能赢就用最小的和齐王最大的比掉,注意这里不管是否存在平局都保证了最优选择;#include"stdio.h" #include"algorithm" using namespace std; #define F(i,n) for((i)=0;(i)<(n);i++) int t[1000],q[1000],n,i,ans,ht,tt,hq,tq; main() { while(scanf 阅读全文

posted @ 2012-02-28 00:48 andy_ 阅读(256) 评论(0) 推荐(0)

HDOJ 2037 今年暑假不AC 贪心
摘要:#include"stdio.h" #include"stdlib.h" typedef struct { int s; int e; }ITEM; int cmp(const void *a,const void *b) { return (*(ITEM *)a).e-(*(ITEM *)b).e; } ITEM a[100],t; main() { int n,cnt,i,j; while(scanf("%d",&n)!=EOF&&n) { for(i=0;i<n;i++)scanf... 阅读全文

posted @ 2012-02-28 00:31 andy_ 阅读(142) 评论(0) 推荐(0)

HDOJ 1789 Doing Homework again贪心
摘要:#include"stdio.h" #include"stdlib.h" #include"string.h" typedef struct{ int score,limit; }HWORK; HWORK a[1001]; int flag[1001]; int cmp(const void *a,const void *b) { return (*(HWORK *)b).score-(*(HWORK *)a).score; } main() { int t,n,i,j,ans; scanf("%d",&t 阅读全文

posted @ 2012-02-28 00:29 andy_ 阅读(139) 评论(0) 推荐(0)

HDOJ1050 Moving Tables 贪心
摘要:#include"stdio.h" main() { int n,s,e,i,j,t,x,max; scanf("%d",&t); while(t--) { int num[200]={0}; scanf("%d",&n); max=-1; for(i=0;i<n;i++) { scanf("%d%d",&s,&e); ... 阅读全文

posted @ 2012-02-28 00:24 andy_ 阅读(145) 评论(0) 推荐(0)

HDOJ1013 Digital Roots
摘要:简单题 不过discuss 中有一位大牛的代码让我想了好长时间。附上他的代码#include<stdio.h> int main() { int a,c; for(;scanf("%1d",&a),a>0;printf("%d\n",--a%9u+1)) while((c=getchar())-48u<10)// 如果c等于空格那么c-48u(结果为unsigned型)将大于10 a+=c-48; return 0; } 阅读全文

posted @ 2012-02-28 00:06 andy_ 阅读(107) 评论(0) 推荐(0)

导航