2011年4月14日

hdu 1280 用sort函数解决。(转载)

摘要: #include<iostream>//2272848 2010-03-31 18:44:28 Accepted 1280 656MS 17868K 609 B C++ 悔惜晟 #include<cstdio>#include<algorithm>using namespace std;const int MAX = 4498501;struct stu{ int sum;}df[MAX];int cmp(stu a, stu b){ return a.sum > b.sum;}int main(){ int n, m, a[3001]; while( 阅读全文

posted @ 2011-04-14 17:43 more think, more gains 阅读(152) 评论(0) 推荐(0) 编辑

hdu 1280用hash解决。。

摘要: 首先什么是hash??“基于比较的”排序复杂度下界是O(nlogn)‏ 但对于某些情况可以更快 现有N个整数,范围在0至10000,如何排序? 建立数组int num[10001],初始化为0,num[i]表示有多少个数等于i 读入一个数a,则num[a]++ 可以达到O(n)复杂度,这个思想就是hashHash的思想n将某个对象对应到一个关键值,然后通过关键值归类,放入到一个表中(哈希表),今后可以根据关键值迅速查找 nHash可以用来判重和统计数目..根据这个思想解决hdu 1280就非常简单了。。。。。 阅读全文

posted @ 2011-04-14 17:41 more think, more gains 阅读(188) 评论(0) 推荐(0) 编辑

hdu 1280 用堆

摘要: 前m大的数Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2922Accepted Submission(s): 1013Problem Description还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。给定一个包含N(N<=3000)个正整数的序列,每个数不超过5000,对它 阅读全文

posted @ 2011-04-14 17:21 more think, more gains 阅读(410) 评论(0) 推荐(0) 编辑

排序 hdu 1236 水题

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>//#include<debug.h>struct node{ char num[30]; int sum; int grade[10]; int t;}R[1001];int cmp(const void *a,const void *b){ if ( (*(node * )a).sum!= (*(node * )b).sum ) return (*(node * )a).sum < (*(node * )b).sum ? 1: -1 阅读全文

posted @ 2011-04-14 13:08 more think, more gains 阅读(301) 评论(0) 推荐(0) 编辑

2011年4月12日

条件编译

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>//#include<debug.h>void Debug () { #ifdef LOCAL freopen ( "in.txt", "r", stdin ); freopen ( "out.txt", "w", stdout ); #endif}int main( ){ int N; Debug(); while(scanf("%d",&a 阅读全文

posted @ 2011-04-12 21:24 more think, more gains 阅读(237) 评论(0) 推荐(0) 编辑

导航