Nuclear reactor
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 11922 Accepted Submission (s): 5420
Problem description There are two types of events occurring in a nuclear reactor:
When the high-energy particle strikes the nucleus, the particle is absorbed, releasing 3 high-energy particles and a low-energy particle.
When the low-energy particle strikes the nucleus, the particle is absorbed, releasing 2 high-energy particles and a low-energy particle.
Assuming that at the beginning (0 microseconds) only one high-energy particle is injected into the nuclear reactor, each microsecond causes an event (for an event where all particles currently present collide with the nucleus), and the number of high-energy and low-energy particles in n microseconds is determined.
Input inputs contain some integer n (0≤n≤33), in microseconds, where n is-1 means the processing is complete.
Output outputs the number of high-energy and low-energy particles in n microsecond time respectively, separated by a comma space between the high energy particle and the low energy particle quantity. Each output occupies one row.
Sample Input
5 2 -1
Sample Output
571 209 One 4 long int against GNU C + +, using __int64 against VC6
SOURCE2006/1/15 ACM Program Design Final Exam//careful;
1#include <stdio.h>2__int64 biao[ *],sieve[ *];3 intMain ()4 {5 intI,j,n;6biao[1]=3; sieve[1]=1;7 for(i=2;i< the; i++)8 {9biao[i]=biao[i-1]*3+sieve[i-1]*2;Tensieve[i]=biao[i-1]+sieve[i-1]; One } A while(~SCANF ("%d", &n) &&n!=-1) - { - if(n==0) theprintf"1, 0\n"); Recently, always forget to judge the initial conditions; - Else -printf"%i64d,%i64d\n", Biao[n],sieve[n]); - } + return 0; -}
Hangzhou Electric 2085--nuclear reactor (play table)