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)