2013年3月29日

摘要: http://acshiryu.com/archives/559 阅读全文
posted @ 2013-03-29 22:17 Fray 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 2.1节 1 insertion-sort(A) 插入排序法 (非降序排列) //复杂度为θ(n^2) 2 3 for j=2 to length[A] 4 5 { 6 7 do key=A[j] 8 9 i=j-110 11 while i>0 and A[i]>key12 13 { 14 15 do A[i+1]=A[i]16 17 i=i-118 19 }20 21 A[i+1]=... 阅读全文
posted @ 2013-03-29 22:01 Fray 阅读(307) 评论(0) 推荐(0) 编辑

2013年3月28日

摘要: http://ecustoj.sinaapp.com/problemshow.php?pro_id=432#include<stdio.h>#include<string.h>int b[1000];int main(){ int a,mid,square,i=0,j,flag; while(scanf("%d",&a)!=EOF) { flag=0; memset(b,9999,sizeof(b)); i=0; while(i<10000) { b[i]=a; ... 阅读全文
posted @ 2013-03-28 22:45 Fray 阅读(123) 评论(0) 推荐(0) 编辑
摘要: http://ecustoj.sinaapp.com/problemshow.php?pro_id=45#include<cstdio>#include<cstring>int N,s[1000005],i=3;int main(){ s[1]=1; s[2]=2; while (i<=1000000) { s[i]=s[i-1]; i++; s[i]=(s[i-2]+s[i>>1])%1000000000; i++; } while(scanf("%d",&N)!= EOF) printf("%d\n" 阅读全文
posted @ 2013-03-28 22:35 Fray 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Book Club http://ecustoj.sinaapp.com/problemshow.php?pro_id=428这道模拟题,应该注意输入输出格式,这里非常容易出问题,几次测试不过都是这里出的问题。#include<cstdio>#include<cstring>using namespace std;int a[50005][55];int vis[50005];int main(){ int N,NQ,P,Q,A,count,i,j; while(scanf("%d %d %d",&N,&NQ,&P)!=EOF 阅读全文
posted @ 2013-03-28 22:33 Fray 阅读(169) 评论(0) 推荐(0) 编辑

2013年3月26日

摘要: 题目http://acm.hdu.edu.cn/showproblem.php?pid=2007此题没有说明先输入的数字一定比后输入的数字小,所以如果不是按序的,那便要更序。#include<stdio.h>int main(){ int st,ed,sum1,sum2,i,t; while(scanf("%d%d",&st,&ed)!=EOF) { if(st>ed) {t=ed; ed=st; st=t;} sum1=0;sum2=0; if(st%2==0) { ... 阅读全文
posted @ 2013-03-26 21:04 Fray 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目http://acm.hdu.edu.cn/showproblem.php?pid=2005这道题也是第一遍没有AC,错误代码如下,问题出在哪里了呢?#include<stdio.h>int main(){ int y,m,d,i,sum=0; int a[11]; a[0]=31; a[2]=31; a[3]=30; a[4]=31; a[5]=30; a[6]=31; a[7]=31; a[8]=30; a[9]=31; a[10]=30; a[11]=31; while(scanf("%d/%d/%d... 阅读全文
posted @ 2013-03-26 19:54 Fray 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目http://acm.hdu.edu.cn/showproblem.php?pid=2001#include <stdio.h>#include <math.h>int main(){ double a,b,c,d,sum; while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d)!=EOF) { sum=sqrt((a-b)*(a-b)+(c-d)*(c-d)); printf("%.2lf\n",sum); } return 0;}这段代码成功的WA了,原因是输入是X1 阅读全文
posted @ 2013-03-26 09:34 Fray 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目http://acm.hdu.edu.cn/showproblem.php?pid=2000第一遍写的代码如下#include<stdio.h>int main(){ char a,b,c,t; while(scanf("%c%c%c",&a,&b,&c)!=EOF) { if(a>b) { t=b; b=a; a=t; } if(b>c) { t=c; c=b; b=t;... 阅读全文
posted @ 2013-03-26 09:12 Fray 阅读(163) 评论(0) 推荐(0) 编辑

导航