Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Car Choice CodeChef Solution

Problem – Car Choice CodeChef Solution

This website is dedicated for CodeChef solution where we will publish right solution of all your favourite CodeChef problems along with detailed explanatory of different competitive programming concepts and languages.
<<Previous CodeChef Problem Next Codechef Problem>>

Car Choice CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    float a,b,c,d;
	    cin>>a>>b>>c>>d;
	    float e=c/a;
	    float f=d/b;
	    if(e<f){
	        cout<<"-1"<<endl;
	    }
	    else if(e==f){
	        cout<<"0"<<endl;
	    }
	    else if(e>f){
	        cout<<"1"<<endl;
	    }
	}
	return 0;
}

Car Choice CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    float a,b,c,d;
	    cin>>a>>b>>c>>d;
	    float e=c/a;
	    float f=d/b;
	    if(e<f){
	        cout<<"-1"<<endl;
	    }
	    else if(e==f){
	        cout<<"0"<<endl;
	    }
	    else if(e>f){
	        cout<<"1"<<endl;
	    }
	}
	return 0;
}

Car Choice CodeChef Solution in PYTH 3

# cook your dish here
t=int(input())
for i in range(t):
    x1,x2,y1,y2=map(int,input().split())
    a=y1/x1
    b=y2/x2
    if a<b:
        print('-1')
    elif a>b:
        print('1')
    else:
        print('0')

Car Choice CodeChef Solution in C

#include <stdio.h>

int main(void) {
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int x1,x2,y1,y2;
        scanf("%d %d %d %d",&x1,&x2,&y1,&y2);
        float a,b;
        a=(float)y1/x1;
        b=(float)y2/x2;
        if(a>b)
        printf("1\n");
        else if(a<b)
        printf("-1\n");
        else 
        printf("0\n");
    }
	// your code goes here
	return 0;
}

Car Choice CodeChef Solution in JAVA

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{Scanner scan = new Scanner (System.in);
		int t= scan.nextInt();
		while(t-->0) {
		    double x1=scan.nextDouble();
		    double x2= scan.nextDouble();
		    double y1= scan.nextDouble();
		   double  y2= scan.nextDouble();
		    double car1=y1/x1;
		    double car2= y2/x2;
		    if (car1<car2)
		    System.out.println("-1");
		    else if (car1==car2)
		    System.out.println("0");
		    else 
		    System.out.println("1");
		}
		// your code goes here
	}
}

Car Choice CodeChef Solution in PYPY 3

t=int(input())
for i in range(t):
    x1,x2,y1,y2=map(int,input().split())
    a=y1/x1
    b=y2/x2
    if a<b:
        print('-1')
    elif a>b:
        print('1')
    else:
        print('0')

Car Choice CodeChef Solution in PYTH

# cook your code here
t=int(input())
for i in range(t):
    (x1,x2,y1,y2)=map(int,raw_input().split(' '))
    a=y1*x2
    b=y2*x1
    if(a>b):
        print("1")
    elif(a<b):
        print("-1")
    else:
        print("0")

Car Choice CodeChef Solution in C#

using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		int x = Convert.ToInt32(Console.ReadLine());
		 double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
                    for (int i = 0; i < x; ++i)
                    {
                        string[] str = Console.ReadLine().Split(' ');
                        x1 = Convert.ToDouble(str[0]);
                        x2 = Convert.ToDouble(str[1]);
                        y1 = Convert.ToDouble(str[2]);
                        y2 = Convert.ToDouble(str[3]);

                        double diesel = (y1 /x1);
                        double petrol = (y2/x2);

                        if (diesel < petrol)
                        {
                            Console.WriteLine("-1");
                        }
                        else if(diesel == petrol)
                        {
                            Console.WriteLine("0");
                        }
                        else
                        {
                            Console.WriteLine("1");
                        }
                    }
	}
}

Car Choice CodeChef Solution in NODEJS

process.stdin.resume();
process.stdin.setEncoding('utf8');

// your code goes here

let input = ''

function checkInput(data) {
    input += data
}

function prepareInput() {
    input = input.split('\n')
}

function main() {
    prepareInput()
    
    let N = input.splice(0, 1) 
    
    for(let i=0; i<N; i++) {
        let [a, b, c, d] = input[i].split(' ').map(Number)
        
        let diesel = c / a
        let petrol = d / b
        
        let ans = diesel < petrol ? -1 
                : diesel > petrol ? 1
                : 0
                
        process.stdout.write(ans + '\n')

    }
}

process.stdin.on('data', checkInput).on('end', main)

Car Choice CodeChef Solution in GO

package main
import (
    "fmt"
    "bufio"
    "os"
)


func Reader(c chan int) {
    scanner := bufio.NewScanner(os.Stdin)

    for scanner.Scan() {
        line := scanner.Text()
        number := 0
        beg := false
        for i := 0; i < len(line); i++ {
            if '0' <= line[i] && line[i] <= '9' {
                beg = true
                number = number * 10 + int(line[i] - '0')
            } else {
                if beg == true {
                    c <- number
                }
                number = 0
                beg = false
            }
        }
        if beg == true {
            c <- number
        }
    }
}


func GetSignOf(num float64) int {
    if num < 0 {
        return -1
    } else if num == 0 {
        return 0
    } else {
        return 1
    }
}


func main(){
    w := bufio.NewWriter(os.Stdout)    
    defer w.Flush()

    inp := make(chan int, 4096)
	go Reader(inp)
	
	t := <-inp
	for i := 0; i < t; i++ {
        x1, x2, y1, y2 := <-inp, <-inp, <-inp, <-inp
        fmt.Fprintln(w, GetSignOf(float64(y1) / float64(x1) - float64(y2) / float64(x2)))
	}
}
Car Choice CodeChef Solution Review:

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

Find on CodeChef

Conclusion:

I hope this Car Choice 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 Programming Language in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

Cognitive Class Answer

CodeChef Solution

Microsoft Learn

Leave a Reply

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