摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2024这是大一的时候做的,今天做了一次忽然wa气死我 ,不过仔细看看还是一定小问题的,原因是因为没有%*c去除了字符垃圾的符号。。。。不过最好还是a了,合法的标识符,是字母或下划线开头,后面的只由数字,字母,下划线组成。。#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int n,i; char a[60]; scanf("%d%*c",&n); while( 阅读全文
posted @ 2011-08-02 22:33
○o尐懶錨o
阅读(775)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2030今天做了以前没有做过的这道题目,其实很简单就是汉字的机内码是由两个负的值组成,所以我们只要遍历过去,看a[i]负数的个数,再除以2即得到了该字符串内汉字的个数。。。代码如下:#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int n; char a[1002]; scanf("%d%*c",&n); while(n--) { gets(a); int k 阅读全文
posted @ 2011-08-02 22:31
○o尐懶錨o
阅读(430)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2035这道题目考察的是余数,因为((a%c)*(b%c))%b=(a*b)%c;所以这道题目就很简单了哦,相信你做了之后也会这样认为的。。。代码::#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int n,m,k; while(scanf("%d%d",&n,&m),n&&m) { k=1; while(m--) { k=k*(n%1 阅读全文
posted @ 2011-08-02 22:30
○o尐懶錨o
阅读(369)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1241今天第一次做DFS的题,虽然这道题目也可以用BFS,不过我还是觉得DFS简单,所以就用DFS,把八个方向的点都置为0,只剩一个2,所以只要查找2的个数即可。。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int hash[120][120];void DFS(int x,int y){ if(x<0||y<0||(hash[x][y]!=2)) return ; if(hash[x][ 阅读全文
posted @ 2011-08-02 22:29
○o尐懶錨o
阅读(145)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2042这道题目果断打表,打表之后一a,感觉以前自己觉得难,不想弄的东西,现在做起来,感觉以前自己的水平太菜了。。。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int a[40];int main(){ a[0]=3; for(int i=0;i<30;++i) { a[i+1]=(a[i]-1)*2; } int t,n; scanf("%d",&t); while( 阅读全文
posted @ 2011-08-02 22:21
○o尐懶錨o
阅读(269)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2070这是一道很明显的水题,菲波拉契数,题目其实已经很明显了,只要找个数组模拟一下,打表就过了代码#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ __int64 a[51]; int n; a[0]=0;a[1]=1; for(int i=2;i<=50;++i) a[i]=a[i-1]+a[i-2]; while(scanf("%d",&n),n!=- 阅读全文
posted @ 2011-08-02 22:20
○o尐懶錨o
阅读(401)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2084这是一道很简单的DP题 ,我觉得就是一种思想,从后面往前面每次找和最大的,把每个数更新,一直往上推就可以了。。。我用了两种方法,一种的递归,一种递推递推代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int a[100][100];void dp(int n){ for(int i=n-1;i>=0;--i) { for(int j=i;j>0;--j) { if(a[i][j]+a[i 阅读全文
posted @ 2011-08-02 22:15
○o尐懶錨o
阅读(717)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1231这道题目还是简单的DP,一开始不懂做,看了看解题报告,觉得有个思想特别好,因为当sum>0时sum加上当前值a[i]肯定比a[i]要大,而Sum<0时肯定要小,所以sum<0时,sum=a[i]。然后再利用max找出最大的和,并且用x,y标记始末位置,这里很巧妙的就可以不用处理0和全是负数的情况了,只有全是负数,max猜可能是负数,当max=0的时候,情况也包括在里面了,wa一次因为数组开小了,把10000看成1000了。。。。代码如下:#include <stdio.h> 阅读全文
posted @ 2011-08-02 22:13
○o尐懶錨o
阅读(275)
评论(0)
推荐(1)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2071其实我觉得这不算一道dp题,它就是简单的暴力就可以了,甚至还可以用冒泡,但是我觉得我还是有点明白dp的思想了,所以把它看成dp吧,一次次记录max;直到最后一个数搜索完了。其实可以不用数组,有点多此一举了。其实真的很简单。。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int t,n; double s[102],max; scanf("%d",& 阅读全文
posted @ 2011-08-02 22:11
○o尐懶錨o
阅读(689)
评论(0)
推荐(1)
摘要:
今天刚刚开通博客园,自己弄了这么久的ACM,是该有个东西记录,以前是在百度空间的记录,可是我还是觉得博客园更好,因为它没有那么花俏吧,从今天以后好好学习,好好记录自己AC的一点一滴。。 阅读全文
posted @ 2011-08-02 20:20
○o尐懶錨o
阅读(159)
评论(1)
推荐(0)

浙公网安备 33010602011771号