Whatsapp Messages

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);
        }
    }
}

Related Posts

CSS Cheatsheet

Transform your web design game with my CSS cheatsheet! Master the art of styling, dive into essential properties and selectors, and create visually stunning websites effortlessly. Whether…

HTML Cheatsheet

Unleash your web development potential with my HTML cheatsheet! Elevate your coding skills, master essential tags and attributes, and build stunning websites with ease. Whether you’re a…

Git&GitHub Cheatsheet

Elevate your Git and GitHub game with my ultimate cheatsheet! Unlock the power of version control, streamline collaboration, and boost productivity. Navigate the complexities of Git commands…

Command Line Cheatsheet

Master the Command Line effortlessly with my comprehensive cheatsheet! Streamline your workflow, boost productivity, and become a command line guru. Unlock essential commands, shortcuts, and tips to…

OpenAI’s APIs Notes

Unlock the potential of OpenAI’s APIs with my comprehensive notes! Dive into the world of cutting-edge artificial intelligence, explore the capabilities of GPT-4 and beyond, and learn…

SQL Notes

Discover the essence of SQL with my comprehensive notes! Dive into the world of Structured Query Language, unraveling the complexities, and mastering database management. Elevate your SQL…

Leave a Reply

Your email address will not be published. Required fields are marked *