We are discussing the Aguinaldo sample problem. This is Part 2 of a series of posts which started here.

The first line of input will contain an integer T, the number of test cases.

The next T lines will contain two space-separated integers, representing the values N and P, in that order.

After the problem statement is the input format. This tells you how the data is arranged. Here, we see a new variable T, which is the number of test cases. This means that your program will need to answer the question T times.

Of course, if we need to solve the problem T times, we need to have T pairs of N and P. As expected, the second part of the input format tells us what N and P are for each test case.

Let’s look at the sample input for a more concrete example:

We see that T = 2. For the first case, N = 3 and P = 500. For the second case, N = 5 and P = 2000. This input format is equivalent to your math teacher giving you an exam with two questions.

The first question will be:

Emilio has 3 relatives. During Christmas, the first relative gives him 500 pesos as a gift. The second relative gives exactly the same amount as the first relative. The third relative gives exactly the same amount as the second relative. How much is the total money that Emilio receives from his relatives?

The second question will be:

Emilio has 2 relatives. During Christmas, the first relative gives him 200 pesos as a gift. The second relative gives exactly the same amount as the first relative.The third relative gives exactly the same amount as the second relative. The fourth relative gives exactly the same amount as the third relative. The fifth relative gives exactly the same amount as the fourth relative. How much is the total money that Emilio receives from his relatives?

Imagine having a teacher who gives you ten problems of this form! At first it will be fine, but then it gets boring since it’s essentially the same problem again and again. Usually, when you figure out how to solve it, then repeating it nine times becomes tedious.

But don’t worry! The good news it that you can write a program that answers this question correctly for any value of N and P. In a way, writing a program that answers the question is proof that you know how to answer any question of that form. No matter what the numbers are.