试管问题(求递推公式)MATRIX MULTIPLICATION CALCULATOR

Eli is a teenager who loves to study chemistry. She recently joined a chemistry research lab.
Dr. Phil wants her to just play around with some chemicals and observe their reaction.
Therefore, he gave her a one-row tray of test tubes with the different chemical inside of them
and told her:

"Mix these chemical together anyhow that you like, but the you have to follow two rules:

Never make a mixture that has two chemicals that their tubes are next to each other.
Keep adding more chemical to the mixture until it is not violating the new rule. "

For example, in the image you can see she was given 5 tubes and she is able to make 4
different mixture without violating the rule: {1,3,5},\ {2,4},\ {2,5},\ {1,4}\ .{1,3,5}, {2,4}, {2,5}, {1,4} .

But she cannot mix 1 and 3 only because she still can add 5 without violating the rules.

She is curious to know how many different mixtures she can make without violating the rule with any
given number of tubes. That’s why she asks you write a code to calculate it for her.
在这里插入图片描述

#include<stdio.h>
#define LASTSUBSCRIPT 80

int main(){
	long long int a[80]={0,0,0,1,2,2,3},T;
	for(int temp = 7;temp <= LASTSUBSCRIPT;temp++)
		a[temp] = a[temp-2]+a[temp-3];
	int N,count=1;
	while(~scanf("%d",&N)){
		if(N==0) break;	
		printf("Case #%d: %lld\n",count++,a[N]+a[N-1]);
	}
	return 0;
}

先打表然后跑

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值