PROBLEM LINK:
Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4
Setter: Kanhaiya Mohan
Tester: Harris Leung
Editorialist: Aman Dwivedi
DIFFICULTY:
Cakewalk
PROBLEM:
In computing, the collection of four bits is called a nibble.
Chef defines a program as:
- Good, if it takes exactly X nibbles of memory, where X is a positive integer.
- Not Good, otherwise.
Given a program that takes N bits of memory, determine whether it is Good or Not Good.
EXPLANATION:
I have two questions for you:
- N is multiple of 4.
- N is not a multiple of 4
Can you guess what happens in the first case?
- As N is a multiple of 4, there won’t be any remainder left and hence it requires exactly some X nibbles. Such types of programs are Good.
Second Case?
- In this case, there will be some remainder left which will require a nibble but it won’t be able to fill the nibble completely. Hence such types of programs are Not Good.
You can print as required by the problem.
TIME COMPLEXITY:
O(1) per test case.
SOLUTIONS:
Setter
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
if(n%4==0) cout<<"Good";
else cout<<"Not Good";
cout<<endl;
}
return 0;
}
Tester
Editorialist
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin>>n;
cout<<((n%4==0)?"Good":"Not Good")<<"\n";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
while(t--)
solve();
return 0;
}