304 North Cardinal St.
Dorchester Center, MA 02124

# True and False Paper CodeChef Solution

## Problem – True and False Paper CodeChef Solution

Alice wrote an exam containing N true or false questions (i.e. questions whose answer is either true or false). Each question is worth 1 mark and there is no negative marking in the examination. Alice scored K marks out of N.

Bob wrote the same exam but he marked each and every question as the opposite of what Alice did, i.e, for whichever questions Alice marked `true`, Bob marked `false` and for whichever questions Alice marked `false`, Bob marked `true`.

Determine the score of Bob.

### Input Format

• The first line contains a single integer T — the number of test cases. Then the test cases follow.
• The first and only line of each test case contains two space-separated integers N and K — the total number of questions in the exam and the score of Alice.

### Output Format

For each test case, output on a new line the score of Bob.

• 1≤T≤2000
• 1≤N≤100
• 0≤KN

### Sample 1:

``````Input: 3
1 1
50 0
100 76
Output: 0
50
24``````

### Explanation:

Test case 1: There was one question in the exam and Alice answered it correctly. This means that Bob will surely answer it incorrectly. Therefore Bob’s score is zero.

Test case 2: Alice answered all the questions incorrectly, and so Bob will surely answer all the questions correctly. Therefore Bob’s score is 50.

### True and False Paper CodeChef Solution in C++17

``````#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
if(t>=1&&t<=2000)
{
while(t--)
{
int n,k;
cin>>n>>k;
cout<<(n-k)<<endl;
}
}
return 0;
}``````

### True and False Paper 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);
int T= scn.nextInt();
for(int i=0; i<T;i++){

int K= scn.nextInt();
int N= scn.nextInt();

System.out.println(K-N);
}
}
}
``````

### True and False Paper CodeChef Solution in Pyth 3

``````t=int(input())
for i in range(t):
n,k=(map(int, input().split()))
print(n-k)``````
##### True and False Paper CodeChef Solution Review:

In our experience, we suggest you solve this True and False Paper 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 True and False Paper CodeChef Solution

Find on CodeChef

##### Conclusion:

I hope this True and False Paper 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