14,662,534 members
Rate this:
See more:
Misty is fond of pokemons and likes to collect pokemon cards. She has P pokemon cards with her at present. She wants to have a particular number of cards on the Dth day. Her friend Ash is ready to help her to achieve the number. Ash will provide her N cards daily so that a day before the Dth day, she will have the required number of Pokemon cards.

Example:

Misty has cards with her, P = 5
D = 6

Ash will provide her with cards daily, N = 4
Ash provides pokemon cards:
Day 1 = 4
Day 2 = 4
Day 3 = 4
Day 4 = 4
Day 5 = 4

Total cards Ash provides = 4 + 4 + 4 + 4 + 4 = 20
Total number of pokemon cards Misty has on the Dth day = 5 + 20 = 25

Misty is busy with her tournament and wants to know the total number of pokemon cards she will have on Dth day. Can you tell her?

Input Format
The first line of input consists of the number of test cases, T

The only line of each test case consists of three space-separated integers, P, N and D.

Constraints
1<= T <=100
1<= D <=100000
0 <= P, N <=100000

Output Format
For each test case, print the required answer in a separate line.

Sample TestCase 1
Input
```2
5 4 6
2 2 2```

Output
```25
4```

Explanation
Test Case 1: As explained in the example.
Test Case 2: P = 2, N = 2, D = 2
Cards provided by Ash on Day 1 = 2
Total number of cards with Misty = 2 + 2 = 4

What I have tried:

Using Phython:
```def main():
n=int(input())
for i in range(n):
li=list(int(i) for i in input().strip().split(' '))
P=li[0]
N=li[1]
D=li[2]
for i in range(D-1):
mul=(D-1)*N
return ans=mul+P

main()```
Posted
Updated yesterday
jeron1 9-Oct-20 14:20pm

Do you have a question?

Rate this:

Solution 1

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you can't work out how to start, try this: How to Write Code to Solve a Problem, A Beginner's Guide[^]
Rate this:

Solution 2

First of all, the languages you list are to tell everyone which language the question is about.

```def main():
n=int(input())
for i in range(n):
li=list(int(i) for i in input().strip().split(' '))
P=li[0]
N=li[1]
D=li[2]
for i in range(D-1): # you need to have a reason for any line of code
mul=(D-1)*N
return ans=mul+P # return is always the last command in a function

main()```

Your code do not behave the way you expect, or you don't understand why !

There is an almost universal solution: Run your code on debugger step by step, inspect variables.
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't know what your code is supposed to do, it don't find bugs, it just help you to by showing you what is going on. When the code don't do what is expected, you are close to a bug.
To see what your code is doing: Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

27.3. pdb — The Python Debugger — Python 3.6.1 documentation[^]
Debugging in Python | Python Conquers The Universe[^]
pdb – Interactive Debugger - Python Module of the Week[^]

The debugger is here to only show you what your code is doing and your task is to compare with what it should do.
Rate this:

Solution 3

```def main():
n=int(input())
for i in range(n):
li=list(int(i) for i in input().strip().split(' '))
p=li[0]
N=li[1]
d=li[2]
for i in range(d-1):
mul=(d-1)*N
ans=mul+p
print(ans)
break
if d==2:
mul=(d-1)*N
ans=mul+p
print(ans)
break
main()```

v2
Dave Kreskowiak 11-Oct-20 11:08am

Do not do someone's homework for them. You're not helping them at all.