alien

Once upon the time, there were aliens come to the earth. In the earth, the reproduction of the alien is by fission on the next day. There are two kinds of the alien, Black Alien and White Alien. The Black Alien could split into three alien, one Black Alien and two White Aliens. While a White alien could split to one Black Alien and one White Alien. The illustration of the alien reproduction is shown below:

Input

The first line is a integer T representing the number of test cases.

Each test case begins with an integer W describes the number of white alien in the coming day (1 ≤ W ≤ 50).

The second line is an integer B describes the number of black alien in the coming day (1 ≤ B ≤ 50)

The third line is an integer L describes how long the aliens stay in days (1 ≤ L ≤ 30)

Output

For each test case, first line is the number of White Alien on the last day of their staying. The second line is the number of Black Alien on the last day of their staying.

Example

Input:


2
3
2
2
45
42
23

Output:

13
18
23775111357
33623084928


Problem Requirement
Runtime Limit : 1 seconds
Memory Limit : 16000 bytes
Looks like an interesting homework assignment.

Good luck!
hahahha
would u help me please...
If we did that, you would get an undeserved grade. Besides, this isn't too hard to do. It's just some math ;)
Last edited on
can u give me some clues...
I really cannot finish it.... :'(
Well, for the memory limit, 16000 bytes == 8000 shorts == 4000 ints/longs

And I am sure you won't need all that, and that it can take well under a second.

So, what are you stuck on?
Last edited on
ok
thanks
i will try that.... :D
My guess is that you are supposed to get input from a file (Runtime Limit : 1 seconds).
If you are not familiar with file I/O this will help -> http://cplusplus.com/doc/tutorial/files/

Obviously, you need to declare some variables to hold the data you'll read from the file. (T, W, B, L)

I would do something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
->  declare T, W, B, L as integers

->  read T from file

->  for every i from 1 to T
    {
        ->  read W, B, L from file

        ->  for every j from 1 to L
            {
                ->  calculate new values for W and B

                    (maybe you will need to declare some
                    more variables here to help you)
            }

        ->  print the results
    }

->  end

If you are not familiar with loops this will help -> http://cplusplus.com/doc/tutorial/control/#loops

Now, if you can show us some code, we'll be very glad to help with whatever problems you're having.
I made a stab at this. But it does not work. I think I got the alien fission math wrong.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
using namespace std;

int main()
{
	unsigned int T, W, w, B, b, L;
	cout << "Please enter the number of cases: ";
	cin >> T;
	cout << endl << endl;
	for(unsigned int i = 0; i < T; i++)
	{
		cout << "Case " << i + 1 << ":" << endl << "Enter the number of White Aliens: ";
		cin >> W;
		cout << "Enter the number of Black Aliens: ";
		cin >> B;
		cout << "Enter how long the Aliens stay in days: ";
		cin >> L;

		for(; L > 0; L--)
		{
			w = W;
			b = B;

			B *= 2;
			W *= 2;
			W += b * 2;
			B += w;

		}

		cout << "Results of Case " << i + 1 << ":" << endl;
		cout << "White Aliens = " << W << endl;
		cout << "Black Aliens = " << B << endl << endl;
	}

	char nothing;
	cin >> nothing;
	return(0);
}


With the given inputs, it does not give the correct outputs...
Yes, it's completely broken. At no point does the problem state that an alien type's quantity doubles. Read it carefully. Note that the text says "divide". If you have a bucket of bacteria and they all divide at the same time, you won't have as many as had before plus twice as many (i.e. three times as many). You'll have as many as you had, plus the same amount (i.e. twice as many).
Topic archived. No new replies allowed.