Whatsapp Messages codechef solution
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
Whatsapp Messages codechef solution
- 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≤101≤Z≤10
Sample Input 1
Whatsapp Messages codechef solution
4
5 2 2
2 2 6
3 2 1
9 1 2
Sample Output 1
6
0
1
16
Explanation
Whatsapp Messages codechef solution
Test case 11: Every hour, Chef receives 55 messages and he reads 22 of them. After 11 hour he will have 33 unread messages and after 22 hours he will have 66 unread messages.
Test case 22: Chef reads all the messages he gets every hour so he has no unread messages.
Test case 33: Chef received 33 messages and read 22 out of them so he has 11 unread message now.
Test case 44: Chef received 1818 messages and read 22 out of them so he has 1616 unread messages now.