PROBLEM LINK:
Setter: utkarsh_adm
Testers: gamegame
Editorialist: kiran8268
DIFFICULTY:
398
PREREQUISITES:
None
PROBLEM:
Alice wrote an exam containing N true or false questions, each worth 1 mark and there is no negative marking in the examination. Bob wrote the same exam but he marked each and every question as the opposite of what Alice did. Our objective is to determine Bob’s score.
EXPLANATION:
Given Alice has scored K marks and each question has 1 mark. Thus the total number of questions Alice attended is K.
Also, Bob has has marked answers opposite of what Alice has marked. Which means for all the questions which Alice marked correct, Bob has marked it incorrect and vice versa.
Now, to find Bob’s score we just need to calculate how many questions were incorrect in Alice’s response.
Thus (N-K) will be Bob’s score
TIME COMPLEXITY:
Time complexity is O(1).
SOLUTION:
Editorialist's Solution
int t;
cin>>t;
while(t--)
{
int n,k;
cin>>n>>k;
cout<<n-k<<"\n";
}