摘要: 题目链接:http://poj.org/problem?id=1611题目大意:有一个学校,有N个学生,编号为0-N-1,现在0号学生感染了非典,凡是和0在一个社团的人就会感染,并且这些人如果还参加了别的社团,他所在的社团照样全部感染,求感染的人数。这道题是并查集的题目。没什么好多说的比较简单~#include<stdio.h>int set[30005],h[30005],num[30005];void init(int m){ int i; for(i = 0;i < m;i++) { set[i] = i; h[i] = 0; ... 阅读全文
posted @ 2012-07-16 23:57 某某。 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 题目连接http://acm.hdu.edu.cn/showproblem.php?pid=1081这道题一开始以为是一个搜索题,一提搜索我就想到什么dfs bfs等等,还有什么并查集一些还么接触过的东西,所以我刚开始的的时候直接放弃,这个也是比赛之后做的。后来看了解题报告知道这是个动态规划。是那个我们比较熟悉的那个最大连续字段和问题的扩展。原动态方程式 dp[i] = dp[i-1] > 0? dp[i-1] + a[i]:a[i];以上是一维方程。而这道题无非是扩展到了二维;所谓的二维矩阵的和,接就是一定行数的在n列中最大的和,也就是同列的相同行数的和的最大值。这个行数也就是可以使任 阅读全文
posted @ 2012-07-16 19:11 某某。 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 这道题一开始看到数很大,马上就想到是大数的问题,然后做了一个__int64的一个表,发现二十多就很不准了,然后就一直以为是大数的问题。练习的时候发现会做的5道题已经做完了,在做也没意思了就开始去网上查答案,然后发现~是一道很明显的数学问题。题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1060我们可以这么考虑,一个数用科学计数法可以记做a1*10n1, ,同样numnum= a*10n,也就是说我们需要求的就是a整数部分,这样用数学的取对数我们可以得到x= num*lg(num) = n+lg(a);所以lg(a) = x-n,也就是说,a = 阅读全文
posted @ 2012-07-16 16:07 某某。 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 编辑器加载#include#include#includechar ans[1000];char yin[1000];void zhuanhua(int i){ int count; count = 0; while(i) { yin[count++] = i%10 + '0'; i = i/10; }}void chengfa(char yin[]){ int i,len1,j,m,y,len2,count; char s[1000]; len1 = strlen(yin); len2 = strlen(ans); count = 0; memset(s,0,sizeof(s 阅读全文
posted @ 2012-07-15 21:46 某某。 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 题目 :http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=276一开始WA了好多遍后来发现是自己的少了中间为零的判断~#include<stdio.h>#include<string.h>int main(){ char s[1000],o; long a,res[1000]; while(scanf("%s %c %ld",s,&o,&a) 阅读全文
posted @ 2012-07-08 17:41 某某。 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=406同样的代码,交了两遍一边AC一边WA。。。很蛋疼= =、、、#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ char a[3000],b[3000],o; double max = 2147483647; doub 阅读全文
posted @ 2012-07-08 00:03 某某。 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 忽略了零的时候的情况啊!!!题目连接http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1047#include<stdio.h>#include<math.h>#include<string.h>char a[300],b[300];int f[600],count;int main(){ while(scanf("%s%s",a,b) == 2) { int len1,len 阅读全文
posted @ 2012-07-03 22:50 某某。 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1756这次主要学会了一个字符串的快速排序函数;int cmp_string(const void* _a,const void* _b){ char* a= (char*)_a; char* b= (char*)_b; return strcmp(a,b);}qsort(word,max,sizeof(word[0]),cmp_string 阅读全文
posted @ 2012-05-30 21:08 某某。 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 这是我原来51cto上博客移植过来的。凑合看吧。不过真的忘了。View Code #include <stdio.h> #include<string.h> int main() { int i,k,l1,l2,ii,j,leap; char s1[1001],s2[1001]; while(gets(s1)!=NULL) { gets(s2); l1=strlen(s1); l2 = strlen(s2);... 阅读全文
posted @ 2012-05-22 19:32 某某。 阅读(223) 评论(0) 推荐(0) 编辑
摘要: Destroy the Well of LifeTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 556Accepted Submission(s): 197Problem DescriptionIn the game of DotA (Defense of the Ancient), there are two opposite legions called The Sentinel and The Scourage.Now The Scour 阅读全文
posted @ 2012-04-22 11:10 某某。 阅读(186) 评论(0) 推荐(0) 编辑