symons

___________每一天都是幸福的!!

  博客园  ::  :: 新随笔  ::  :: 订阅 订阅  :: 管理
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 22 下一页

2014年1月6日

摘要: char类型占一个字节int类型占4个字节如果杭电OJ上给的范围是32678K,那么内存大小就是32678*1024=33554432那么可以开到多大的数组呢?!可以开到很大,但是可用的就只有33554432/4=838万.我在杭电上试了一下,num[8000000](八百万),而且给其赋值的话,不会超内存num[9000000](900万),而且给其赋值的话,会超内存开了一个num[90000000](9000万),不对其赋值,只是开着放在那里的话,不会超内存所以如果题目要求给出的不是很大的话,特别是字符串题目的话,大家最好提前计算一下,然后根据限制寻找最优算法。ok,that's 阅读全文
posted @ 2014-01-06 20:16 symons 阅读(533) 评论(0) 推荐(0)

2014年1月4日

摘要: 这题目比较简单,把思路搞清楚就可以啦。#include #include char words[10000+10][20];int init(){ int cnt=0; while(~scanf("%s",words[cnt])){ if(strcmp("#",words[cnt])==0) return cnt; cnt++; }}int judge(char a[],char b[]){ int success; int la=strlen(a); int lb=strlen(b); int i,j,k; int ... 阅读全文
posted @ 2014-01-04 20:35 symons 阅读(174) 评论(0) 推荐(0)

2014年1月3日

摘要: 这题目比较简单,看题干就能看出来。求逆序数,我用的是O(n^2)的算法,数据也不大,水过。也可以用归并排序来做。 1 #include 2 #include 3 #include 4 struct node{ 5 char str[100]; 6 int cnt; 7 int num; 8 }str[110]; 9 bool cmp(node a,node b){10 if(a.cnt==b.cnt) return a.numstr[cas].str[j])25 str[cas].cnt++;26 ... 阅读全文
posted @ 2014-01-03 23:16 symons 阅读(172) 评论(0) 推荐(0)

摘要: 这题目只要读懂了意思就好做了,先求出来(0.0)到(x.y)的距离为r,然后求出来以r为半径的半圆的面积,然后再用这个面积除以50,再向上取整就可以啦。 1 #include 2 #include 3 #include 4 #define eps 0.000000001 5 #define pie 3.1415926 6 int main(){ 7 int t; 8 double res; 9 double area;10 double r;11 double x,y;12 int cnt=1;13 scanf("%d",&t)... 阅读全文
posted @ 2014-01-03 21:53 symons 阅读(163) 评论(0) 推荐(0)

2014年1月2日

摘要: 历法的转换。 1 #include 2 #include 3 #include 4 char Haab[19][10]={ 5 "pop","no","zip","zotz","tzec","xul","yoxkin","mol", 6 "chen","yax","zac","ceh","mac","kankin",& 阅读全文
posted @ 2014-01-02 21:54 symons 阅读(150) 评论(0) 推荐(0)

摘要: 英语真差劲啊,看题目没看明白,无奈重新开始手抄题目,突然发现一句话 “For each cycle,you will be given the number of days form the beginning of the current year at which one of its peaks occurs. " 看到这句才反应过来应该把前三个值分别取余,好笨啊! 1 #include 2 #include 3 int main(){ 4 int k,i,n,j; 5 int a,b,c,d; 6 int cnt=0; 7 while(~scanf... 阅读全文
posted @ 2014-01-02 18:36 symons 阅读(144) 评论(0) 推荐(0)

2014年1月1日

摘要: 这题目,用G++ WA,用C++ AC。题目要求,现给出n个球,然后要使每两个球直接或者间接连通,可以在任意两球之间做管道(在表面),最后的要求是,如果使得都连通的话,管道最小长度是多少。思路简单,就是求出来每两个球之间的距离,球心差减去两球的半径,注意如果这里是负的则处理为0。然后就是克鲁斯卡尔求最小生成树就可以了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define eps 0.00000001 7 struct point{ 8 double x,y,z,r; 9 }p[1... 阅读全文
posted @ 2014-01-01 20:10 symons 阅读(198) 评论(0) 推荐(0)

摘要: 这题目思路很清晰,qsort+swith,case+结构体。写完以后很速度的给我tle了。然后我就各种改,始终没有改进的就是qsort,我就各种纠结,之前一直以为qsort和sort差不多速度,然后我去disscuss那里看大神的代码。发现了2种很巧妙的处理方式一种是hash[26]={2,2,2,......8,8};这种的,用c-'A'来代表键值,然后就对应到相应的按键了。第二种是一种巧妙的处理方式 res+=((str[i]-'A'-(str[i]>'Q'))/3+2); 第三种就是我自己写的那个啦,swith,case。然后我发现我 阅读全文
posted @ 2014-01-01 13:13 symons 阅读(188) 评论(0) 推荐(0)

2013年12月24日

摘要: 这题目主要是难在字符串处理这块。 1 #include 2 #include 3 #include 4 #define mod 999983 5 struct node{ 6 char str[10+100]; 7 char res[10+100]; 8 node *next; 9 }p[mod];10 int sign[mod];11 void hash(char str[],char res[]){12 int i,l=strlen(str);13 int key=0;14 for(i=0;inext!=NULL)23 ... 阅读全文
posted @ 2013-12-24 00:32 symons 阅读(335) 评论(0) 推荐(0)

2013年12月23日

摘要: 虽然这题目我曾经在我们学校OJ上做过但是我那时候是用的暴力做的,这次我用的是哈希写的,我写这题目时候开始是在main函数里面写哈希感觉很麻烦很不清晰,然后我换用函数来写,清晰了很多,写完就AC了。用哈希存储前两项的值,然后遍历后三项再去哈希表中寻找这个值在前两项中出现的次数,加起来就OK了。 1 #include 2 #include 3 #include 4 #define aabs(x) (x)>0?(x):-(x) 5 #define mod 999983 6 #define t(x) (x)*(x)*(x) 7 struct node{ 8 int nu... 阅读全文
posted @ 2013-12-23 18:22 symons 阅读(484) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 22 下一页