上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页
  2012年7月22日
摘要: 卡特兰数的模拟。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>usingnamespacestd;#defineMAX101#defineBASE10000inta[101][MAX];voidmultiple(inta[],intsize,intb){inti,j;intcarry=0;for(i=size-1;i>=0;i--){carry+=a[i]*b;a[i]=carry%BASE;carry=carry/BASE;}return 阅读全文
posted @ 2012-07-22 17:40 有间博客 阅读(232) 评论(0) 推荐(0)
摘要: 数学题,用hash记录元素出现次数,有重复那么马上退出。循环次数最多为mod次就可以判断是否重复。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;constintmaxn=100001;inthash[maxn];intmain(){intstep,mod;while(~scanf("%d%d",&step,&mod)){inti;intflag=0;intans=0;memset(hash,0,sizeof(hash) 阅读全文
posted @ 2012-07-22 15:27 有间博客 阅读(313) 评论(0) 推荐(0)
摘要: 简单模拟题。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>usingnamespacestd;constintmaxn=201;intM1,M2,R1,R2,R3;chars[maxn];intmain(){while(~scanf("%d%d",&M1,&M2)){inti,j;R1=R2=R3=0;scanf("%s",s);intl=strlen(s);for(i=0;i<l; 阅读全文
posted @ 2012-07-22 10:28 有间博客 阅读(144) 评论(0) 推荐(0)
  2012年7月21日
摘要: 模拟高精度。第一天由于输入的时候判断是否为0,结果果断超时。额。。。结果第二天重新写的时候马上AC了。泪奔!CODE:#include<cstdio>#include<cstdlib>#include<cstring>usingnamespacestd;constintmaxn=535;intfibo1[maxn];intfibo2[maxn];intfibo3[maxn];intfibo4[maxn];intresult[maxn];voidoutput()//输出{inti;for(i=maxn-1;i>=0&&result[i]= 阅读全文
posted @ 2012-07-21 21:17 有间博客 阅读(164) 评论(0) 推荐(0)
摘要: 简单模拟题。CODE:#include"stdio.h"#include"string.h"#include"stdlib.h"#include"math.h"#include"ctype.h"usingnamespacestd;chara[101],str[101];intmain(){inti,j;intt;scanf("%d",&t);getchar();while(t--){gets(a);intlen=strlen(a);i=0;j=0;while(a[i] 阅读全文
posted @ 2012-07-21 21:13 有间博客 阅读(281) 评论(0) 推荐(0)
摘要: 简单模拟题。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;constintmaxn=10001;intprime[maxn];intvis[maxn]={0};inttot;voidinit(){inti,j;for(i=2,tot=0;i<maxn;i++)if(!vis[i]){prime[tot++]=i;for(j=i*i;j<maxn;j+=i)vis[j]=1;}return;}intis_prime(intv){intl=0,h 阅读全文
posted @ 2012-07-21 20:10 有间博客 阅读(390) 评论(0) 推荐(0)
摘要: 思路:一开始我也不会写,最主要的就是不好分辨运算符的优先级。最后我去网上参考了别人的代码,然后自己顺着别人的思路想了想,就有了一下的代码!CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>usingnamespacestd;constintmaxn=201;chars[maxn];intp,l;doubleget()//先算a*b或者a/b的值. {doublea,b;charopt;a=0.0;while(isdigit(s[p])){a*=10 阅读全文
posted @ 2012-07-21 16:31 有间博客 阅读(398) 评论(0) 推荐(0)
摘要: 简单模拟题。只要理解了题意,基本上都写得出的。思路1:首先知道求的是素数,那么通过筛选法打表。由于p/q<=1 --> p <= sqrt(m); a/b <= p/q --> a*q <= b*p;p*q的值要最大,那么就枚举所有的值那么就可以求出正确的数字啦。(优化过的代码,顺便复习下最基础的东西,其实直接枚举也可以过的~)CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>usingnamespacestd;c 阅读全文
posted @ 2012-07-21 11:51 有间博客 阅读(318) 评论(0) 推荐(0)
  2012年7月20日
摘要: 第一个记忆化搜索,理解得差不多啦。贴下代码咯~CODE:1#include<stdio.h>2#include<stdlib.h>3#include<string.h>4usingnamespacestd;56intFIB[1001];78intfib(intn)9{10inti;11if(n>2)returnFIB[n]==-1?FIB[n]=fib(n-1)+fib(n-2):FIB[n];12elsereturn1;1314}151617intmain()18{19intn;20memset(FIB,-1,sizeof(FIB));21FIB[0 阅读全文
posted @ 2012-07-20 22:01 有间博客 阅读(670) 评论(0) 推荐(0)
摘要: 开始以为好难,会无限循环。后来发现题目中有一定会得到1这句话,那么就轻易AC了。好开心呐!~CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;constintmaxn=300001;__int64odd[maxn];inttot;voidprint(intn){tot=0;if(n==0){printf("Nonumbercanbeoutput!\n");return;}while(n!=1){if(n&1){odd[tot++] 阅读全文
posted @ 2012-07-20 21:35 有间博客 阅读(216) 评论(0) 推荐(0)
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页