Playlist CodeChef Solution

Problem – Playlist CodeChef Solution

Chef’s playlist contains 3 songs named A,B, and C, each of duration exactly X minutes. Chef generally plays these 3 songs in loop, i.e, ABCABCA→…

Chef went on a train journey of N minutes and played his playlist on loop for the whole journey. How many times did he listen to the song C completely?

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases. The description of the test cases follows.
  • Each test case consists of a single line of input, containing two space-separated integers N,X.

Output Format

For each test case, output on a new line the number of times Chef listens to the song C completely.

Constraints

  • 1≤T≤1000
  • 1≤N≤100
  • 1≤X≤10

Sample 1:

Input: 5
6 1
5 1
11 2
5 8
100 9
Output: 2
1
1
0
3

Explanation:

Test case 1: Since each song is of duration 1 minute and the journey is 6 minutes long, Chef listens each of the songs A,B,C twice.

Test case 2: Since each song is of duration 1 minute and the journey is 5 minutes long, Chef listens the songs A,B twice but C only once.

Test case 3: Since each song is of duration 2 minutes and the journey is 11 minutes long, Chef listens the songs A,B twice but C only once. Note that Chef is in the middle of listening to song C for the second time when the journey ends, but it is not counted since he hasn’t listened to it fully.

Test case 4: Chef cannot hear any song since the journey is shorter than his song duration.

Playlist 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 scn= new Scanner(System.in);    //System.in is a standard input stream  
        int T= scn.nextInt();
        
       for(int i=0; i<T; i++){
        int N= scn.nextInt();
        int X= scn.nextInt();
       
            System.out.println(N/(X*3));
        
       }
	}
}

Playlist CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    int a,b;
	    cin>>a>>b;
	    int total = b*3;
	    int c = a/total;
	    cout<<c<<endl;
	}
	return 0;
}

Playlist CodeChef Solution in Pyth 3

T = int(input())
for i in range(T):
    N,X=map(int,input().split())
    A=(N//3)//X
    print(A)
Playlist CodeChef Solution Review:

In our experience, we suggest you solve this Playlist 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 Playlist CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Playlist 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.