www.bersaty.com

06 2011 档案

摘要:水~~找规律#include<iostream>using namespace std;int cow(int n){ if(n>4) return cow(n-1)+cow(n-3); else return n;}int main (){ int n; while(cin>>n&&n) printf("%d\n",cow(n)); return 0;} 阅读全文
posted @ 2011-06-27 21:51 bersaty 阅读(193) 评论(0) 推荐(0)
摘要:2000~2007//2000 http://acm.hdu.edu.cn/showproblem.php?pid=2000#include<stdio.h>#include<string.h>void main(){ char str[4],t; int i; while(scanf("%s",str)!=EOF) { for(i=0;i<2;i=i++) { if(str[i]>str[i+1]) { t=str[i]; str[i]=str[i+1]; str[i+1]=t; } } for(i=0;i<2;i=i++) { 阅读全文
posted @ 2011-06-27 20:43 bersaty 阅读(266) 评论(0) 推荐(0)
摘要:初看到这题就想到fibonacci数,算了几个,果然!!#include<iostream>using namespace std;int main(){ int n,m,a[45],i; a[1]=0; a[2]=1; a[3]=2; for(i=4;i<=40;i++) a[i]=a[i-1]+a[i-2]; while(scanf("%d",&n)!=EOF) { while(n--) { scanf("%d",&m); printf("%d\n",a[m]); } } return 0;} 阅读全文
posted @ 2011-06-20 17:22 bersaty 阅读(367) 评论(0) 推荐(1)