In: Computer Science
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.
Assuming that first line will have the number of test cases followed by each line having three space separated integers P, N and D, we can get the total number of cards a day before Dth day as follows:
In python
t = int(input())
for i in range(t):
p, n, d = map(int, input().split())
total = p + n*(d-1)
print(total)
In c++
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
for(int i=0; i<t; i++) {
int n, p, d, total;
cin >> p >> n >> d;
total = p + (n*(d-1));
cout<<total<<"\n";
}
}
In java
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i = 0; i<t; i++) {
int p = sc.nextInt();
int n = sc.nextInt();
int d = sc.nextInt();
int total = p + (n*(d-1));
System.out.println(total);
}
}
}