The chef recently installed Whatsapp on his mobile device. Currently, he has no unread messages.
Every hour, he receives XX messages and he is able to read YY messages out of them. After some time Chef notices that he has several unread messages.
Can you tell him exactly how many unread messages Chef has after ZZ hours have passed?
Input Format
- The first line of input will contain a single integer TT, denoting the number of test cases. The description of the test cases follows.
- Each test case consists of a single line containing three space-separated integers X, Y, X, Y, and Z$, denoting the number of messages Chef receives every hour, the number of messages he reads every hour, the and number of hours that have passed, respectively.
Output Format
- For each test case, output on a new line a single integer denoting the number of unread messages after ZZ hours.
Constraints
- 1≤T≤2⋅1041≤T≤2⋅104
- 1≤Y≤X≤501≤Y≤X≤50
- 1≤Z≤10
//This code is written by Souvik Ghosh
import java.util.*;
public class whatsappMessages {
public static void main(String[] args) {
//copy from here for codechef
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
for (int i = 0; i < t; i++) {
int x=sc.nextInt();
int y=sc.nextInt();
int z=sc.nextInt();
int ur=((x*z)-(y*z));
System.out.println(ur);
}
}
}