Counting Words CodeChef Solution

Problem – Counting Words CodeChef Solution

Harsh was recently gifted a book consisting of N pages. Each page contains exactly M words printed on it. As he was bored, he decided to count the number of words in the book.

Help Harsh find the total number of words in the book.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two space-separated integers on a single line, N and M — the number of pages and the number of words on each page, respectively.

Output Format

For each test case, output on a new line, the total number of words in the book.

Constraints

  • 1 \leq T \leq 1001≤T≤100
  • 1 \leq N \leq 1001≤N≤100
  • 1 \leq M \leq 1001≤M≤100

Sample 1:

Input: 4
1 1
4 2
2 4
95 42
Output: 1
8
8
3990

Explanation:

Test case 1: The book consists of only 1 page, and each page has only 1 word. Hence, the total number of words is 1.

Test case 2: The book consists of 4 pages, and each page has 2 words. Hence, the total number of words is 2+2+2+2=8.

Test case 3: The book consists of 2 pages, and each page has 4 words. Hence, the total number of words is 4+4=8.

Test case 4: The book consists of 95 pages, and each page has 42 words. Hence, the total number of words is 3990.

Counting Words CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int N,M;
	    cin>>N>>M;
	    cout<<N*M<<endl;
	}
	return 0;
}

Counting Words CodeChef Solution in Python3

# cook your dish here
t=int(input())
while t!=0:
    n,m=map(int,input().split())
    print(n*m)
    t-=1

Counting Words CodeChef Solution in Java

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int i=0;i<T;i++){
		    int m = sc.nextInt();
		    int n = sc.nextInt();
		    System.out.println(m*n);
		}
	}
}
Counting Words CodeChef Solution Review:

In our experience, we suggest you solve this Counting Words CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Counting Words CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Counting Words CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

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