摘要: 解题思路:看过题就知道是要找规律的,而从下列式子中不难发现, S(1)=1,//在s(n)从左往右看 S(2)=11, s(1)中有1个1; S(3)=21, s(2)中有2个1; S(4)=1211, s(3)中有1个2和1个1; S(5)=111221,s(4)中有1个1、1个2和2个1; S(6)=312211, s(5)中有3个1、2个2和1个1;……让求s(n)的长度,首先必须找出 s(n)的组成结构,其实仔细一看,会发现s(n)的组成是跟 s(n-1) 密切相关的,过程如上所述。由于 n<=30,数据不大,我就定义了一个二维字符数组来保存s(n)的所有信息,然后就可以求出所需 阅读全文
posted @ 2012-04-17 22:33 zhongya 阅读(131) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int main() 5 { 6 int ncases; 7 char b[21], g[21], x[20]; 8 9 scanf("%d",&ncases);10 while( ncases-- )11 {12 scanf("%s%s%s",b,g,x);13 printf("%s will survive\n",g);14 }15 system("pause"); 16 阅读全文
posted @ 2012-04-17 22:30 zhongya 阅读(91) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<stdlib.h> 4 5 int main() 6 { 7 int ncases, d, t; 8 double n1, n2, num1,num2,k; 9 int sum1, sum2;10 11 scanf("%d",&ncases);12 while( ncases-- )13 {14 scanf("%d%d",&d,&t);15 num1 = 0.0; num2 = 阅读全文
posted @ 2012-04-17 22:29 zhongya 阅读(134) 评论(0) 推荐(0) 编辑