随笔分类 -  水题系列

大多是hdu11页的题目吧
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1339这是一道很简单的英文题,就是求2^p与一个o相乘等于n,这样看来o一定是一个奇数,所以我们只要不断除以2一定可以得到一个奇数,若n是一个奇数就直接把n和0输出就可以了代码:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ int t,n,c; scanf("%d",&t); while(t--) { c=0; 阅读全文
posted @ 2011-08-04 11:34 ○o尐懶錨o 阅读(268) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2069这道题一看就是母函数,于是就觉得它很简单,出现了错误的代码:#include<stdio.h>int main(){ int n; int i,j,k; int a[1000],b[1000],num[6]={0,1,5,10,25,50}; while(scanf("%d",&n)!=EOF) { for(i=0;i<=n;i++) { a[i]=1; b[i]=0; } for(i=2;i<=5;i++) { for(j=0;j<=n;j++ 阅读全文
posted @ 2011-08-04 10:05 ○o尐懶錨o 阅读(197) 评论(0) 推荐(1)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2031今天下午翻到11页突然发现我的水题系列还有好多没有做,呵呵,一试手感还不错,只是一个小小的错误,wa。。。。本题就是利用assic码值,用字符串读出更方便吧,不过一改就对了,感觉真不错。。。#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int m,n,r,a[1000],k,flag; while(scanf("%d%d",&n,&m)!=EO 阅读全文
posted @ 2011-08-03 16:15 ○o尐懶錨o 阅读(669) 评论(0) 推荐(1)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2028深夜十二点水的题,第一次wa,不过后来看看很简单,gcd求最大公约数,然后每次求出最小公倍数。。。最后知道用该数除以最大公约数再乘以本身就可以了#include <stdio.h>#include <string.h>#include <stdlib.h>int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int main(){ int n,a,b,k; while(scanf("%d",&n)! 阅读全文
posted @ 2011-08-03 15:59 ○o尐懶錨o 阅读(1325) 评论(0) 推荐(1)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2029这是一道回文串,以前我老是用for循环,不过今天试了试while觉得还挺好用的,呵呵,果断、一a了 。。好开心啊 ,今天有个好的开始不错哦!回文就是前面和后面一直匹配。。。若有不同的就跳出并且输出no,若一直到最后都没有不同就输出yes#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int n,m; char a[10002]; scanf("%d",& 阅读全文
posted @ 2011-08-03 15:54 ○o尐懶錨o 阅读(302) 评论(0) 推荐(1)
摘要: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 阅读(432) 评论(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=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 阅读(402) 评论(0) 推荐(1)