随笔分类 -  ACM水题

摘要:题目:HEUOJ:http://acm.hrbeu.edu.cn/index.php?act=problem&id=1001&cid=18现在发现总是忘记数组初始化,很烦额~~~AC代码:#include<stdio.h>#include<string.h>#include<stdlib.h>#define MAX 100005typedef struct node{ char s[25];}node;node ss[MAX];int num[MAX];int cmp1(const void *a,const void *b){ struct 阅读全文

posted @ 2011-03-27 21:59 江南烟雨hust 阅读(164) 评论(0) 推荐(0)

摘要:题目:http://acm.nyist.net/JudgeOnline/problem.php?pid=28大数阶乘时间限制:3000 ms | 内存限制:65535 KB 难度:3描述 我们都知道如何计算一个数的阶乘,可是,如果这个数很大呢,我们该如何去计算它并输出它? 输入 输入一个整数m(0<m<=5000) 输出 输出m的阶乘,并在输出结束之后输入一个换行符 样例输入 50样例输出 30414093201713378043612608166064768844377641568960512000000000000来源 经典题目 上传者 张云聪 代码提交中...... 请勿提交 阅读全文

posted @ 2011-03-23 16:30 江南烟雨hust 阅读(230) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1894先排序,再进行判断是否是前缀,可以明显提高效率;AC代码:#include<stdio.h>#include<string.h>#include<stdlib.h>typedef struct node{ char s[33];}node;node w[50005];int cmp(const void *a,const void *b){ struct node *c=(struct node *)a; struct node *d=(struct node 阅读全文

posted @ 2011-03-22 19:01 江南烟雨hust 阅读(178) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=2203AC代码:#include<stdio.h>#include<string.h>#define MAXLEN 100005char s1[MAXLEN],s2[MAXLEN];int IsSubset(int len1,int len2){ int i,j,k; for(i=0;i<len1;i++){ if(s1[i]==s2[0]){//遇到字符与s2首字符相等; j=i+1; k=1; while(k<len2&&s1[j]==s2[k]& 阅读全文

posted @ 2011-03-21 14:23 江南烟雨hust 阅读(206) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=2206这道题要考虑的地方很多:1、是否含有除0-9、.之外的字符;2、.的个数是否是3个;3、4部分的数值是否都在0-255之间;4、是否有连续的.;考虑到这几个方面,基本上就能AC了。我测试了好多数据,终于AC了~~~我的AC代码:#include<stdio.h>#include<string.h>int IllegleChar(char c){ if((c>='0'&&c<='9')||c=='.' 阅读全文

posted @ 2011-03-20 21:04 江南烟雨hust 阅读(208) 评论(0) 推荐(0)

摘要:题目啊:http://acm.hdu.edu.cn/showproblem.php?pid=1727我的方法很笨,不知道有没有什么好方法~~~这道题说实话,也不是很水,要考虑的方面其实很多的,我调了好半天,终于由WA变为AC,不容易啊~~~AC代码:#include<stdio.h>char s[10][10]={"zero","one","two","three","four","five","six","seven",& 阅读全文

posted @ 2011-03-20 20:01 江南烟雨hust 阅读(171) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1200AC代码:#include<stdio.h>#include<string.h>int main(){ int c,len,i,j,k,row,count,flag; char s1[201],p[21][201],s2[201]; while(scanf("%d",&c)!=EOF){ //c表示列数; getchar();//接受回车符; if(c==0){ break; } gets(s1); len=strlen(s1); i=0; ro 阅读全文

posted @ 2011-03-20 15:10 江南烟雨hust 阅读(198) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=2115题目有一句话:“Output a blank line between two cases.“。开头提交Presentation Error,很是上火!!!总是忽略这个地方,调了半天~~~终于AC~~~AC代码:#include<stdio.h>#include<string.h>#include<stdlib.h>//包含qsort函数的头文件;struct node{//运动员结构体定义; char name[20],time[6]; int t;//时间( 阅读全文

posted @ 2011-03-18 18:46 江南烟雨hust 阅读(147) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1159问题的递归式写成:代码:#include<stdio.h>#include<string.h>#define MAXLEN 505void LCSLength(char *x,char *y,int m,int n,int c[][MAXLEN]){//求最长公共子序列; int i,j; for(i=0;i<=m;i++){ c[i][0]=0; } for(i=0;i<=n;i++){ c[0][i]=0; } for(i=1;i<=m;i++){ f 阅读全文

posted @ 2011-03-17 14:53 江南烟雨hust 阅读(220) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1702定义字符串数组的时候原来是这样写的:char s[4],p[3];结果总是不对,调了半天啊。。。看来开数组的时候只要不影响空间可以适当开大一点。。。。。AC代码:#include<stdio.h>#include<string.h>#define maxsize 1000int main(){ int n,m,temp,stack[maxsize],top,front,rear; //用数组模拟队列、栈; char s[5],p[4];//记录进出栈方式; scanf(&q 阅读全文

posted @ 2011-03-16 21:20 江南烟雨hust 阅读(375) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=3792总是超时,搞了半天才搞好,抑郁。。。。。。。。。。。。。。。。。。。。。。代码:[服务器生成] 通行证:KSDA291730794 密码:21024731 #include<stdio.h> #include<math.h> #define N 100000 int main(){ int n,i,j,temp,a[N],b[N]; a[0]=a[1]=0; for(i=2;i<N;i++){ a[i]=1;//数组初始化; } temp=(int)sqrt(N); 阅读全文

posted @ 2011-03-14 20:59 江南烟雨hust 阅读(202) 评论(0) 推荐(0)

摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=3793代码:#include<stdio.h>#include<string.h>int IsSymmetric(char s[],int len){//判断字符串是否对称; int flag,i; flag=1; for(i=0;i<len/2;i++){ if(s[i]!=s[len-1-i]){ flag=0; break; } } return flag;}void shiftLeft(char s[],int len){//把字符串循环左移一次; int i; c 阅读全文

posted @ 2011-03-14 11:17 江南烟雨hust 阅读(228) 评论(0) 推荐(0)

导航