High Accuracy CodeChef Solution

Problem – High Accuracy CodeChef Solution

There are 100 questions in a paper. Each question carries +3 marks for correct answer, -1 marks for incorrect answer and 0 marks for unattempted question.

It is given that Chef received exactly X (0≤X≤100) marks. Determine the minimum number of problems Chef marked incorrect.

Input Format

  • First line will contain T, number of test cases. Then the test cases follow.
  • Each testcase contains of a single integer X, marks that Chef received.

Output Format

For each test case, output the minimum number of problems Chef marked incorrect.

Constraints

  • 1≤T≤100
  • 0≤X≤100

Sample 1:

Input: 4
0
100
32
18
Output: 0
2
1
0

Explanation:

Test Case 1: It might be possible that Chef didn’t attempt any question in which case he didn’t get any question incorrect.

Test Case 2: For the case when Chef got 34 questions correct and 2 questions incorrect, Chef marked minimum incorrect questions.

Test Case 3: For the case when Chef got 11 questions correct and 1 question incorrect, Chef marked minimum incorrect questions.

Test Case 4: For the case when Chef got 6 questions correct and no question incorrect, Chef marked minimum incorrect questions.

High Accuracy CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while (t--)
	{
	    int x;
	    cin>>x;
	    if (x%3==0)
	    cout<<0<<endl;
	    else if (x%3==2)
	    cout<<1<<endl;
	    else
	    cout<<2<<endl;
	}
	return 0;
}

High Accuracy CodeChef Solution in Pyth 3

# cook your dish here
for _ in range(int(input())):
    x=int(input())
    if x==0 or x%3==0:
        print(0)
    else:
        print((((x//3)+1)*3)-x)

High Accuracy 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
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		for (int i=0;i<t ;i++ ){
		    int x=sc.nextInt();
		    if ((x%3)==0){
		        System.out.println(0);
		    }else if ((x%3)!=0){
		        if ((x%3)==1){
		            System.out.println(2);
		        }  
		         if ((x%3)==2){
		            System.out.println(1);
		        }  
		    }  
		} 
	}
}
High Accuracy CodeChef Solution Review:

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

Find on CodeChef

Conclusion:

I hope this High Accuracy 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 *