HDOJ 2085 核反应堆


核反应堆

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 15055    Accepted Submission(s): 6787


Problem Description
某核反应堆有两类事件发生:
高能质点碰击核子时,质点被吸收,放出3个高能质点和1个低能质点;
低能质点碰击核子时,质点被吸收,放出2个高能质点和1个低能质点。
假定开始的时候(0微秒)只有一个高能质点射入核反应堆,每一微秒引起一个事件发生(对于一个事件,当前存在的所有质点都会撞击核子),试确定n微秒时高能质点和低能质点的数目。
 

Input
输入含有一些整数n(0≤n≤33),以微秒为单位,若n为-1表示处理结束。
 

Output
分别输出n微秒时刻高能质点和低能质点的数量,高能质点与低能质点数量之间以逗号空格分隔。每个输出占一行。
 

Sample Input
  
  
5 2 -1
 

Sample Output
  
  
571, 209 11, 4 提示 可以使用long long int对付GNU C++,使用__int64对付VC6
 

Source
 

Recommend
lcy   |   We have carefully selected several similar problems for you:   2082  2086  2079  2091  2077 
 


思路:

递推公式很容易就能够导出,在递推有

	Big[j] = 3*Big[j-1] + 2*Little[j-1];//大的
		Little[j] = Big[j-1] + Little[j-1];//小的

AC CODE:

#include<stdio.h>
#include<cstring>
#include<algorithm>
#define HardBoy main()
#define ForMyLove return 0;
using namespace std;
typedef long long LL;
const int MYDD = 1103;

LL Big[64] = {1, 3, 11}, Little[64] = {0 ,1, 4};
void Init() {//初始化
	for(int j = 3; j <= 33; j++) {
		Big[j] = 3*Big[j-1] + 2*Little[j-1];//大的
		Little[j] = Big[j-1] + Little[j-1];//小的
	}
}

int HardBoy {
	int n;
	Init();
	while(scanf("%d", &n) && (n != -1)) {
		printf("%lld, %lld\n", Big[n], Little[n]);
	}
	ForMyLove
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值