Vaccination Date(https://www.codechef.com/CBST2021/problems/VACNN)

Practice

Author: noob_tech
Tester: noob_tech
Editorialist: noob_tech

DIFFICULTY:

CAKEWALK, SIMPLE, EASY.

PREREQUISITES:

Math .

PROBLEM:

You work in a private company. Your company decided to start the Vaccination Process in the company.Due to the Shortage of vaccines company has decided some rules which are given below.

RULES

  1. Worker’s Age must be greater than or equal to 24(i.e Age>=24).

  2. Worker’s Last Four digit of Aadhaar Number should be the power of two.(For eg. 2048).

You are a tech guy,Company workers give you his/her last four-digit Aadhaar number and his/her Age to know whether he/she is eligible for vaccination or not.

NOTE-If Workers are eligible for vaccination then Print YES else Print NO.

QUICK EXPLANATION:

We are given age and last four digit of aadhar number.
According to given rules we have to check age must be greater than and equal to 24 and last four digit aadhar number must be in power of two.

EXPLANATION:

Here,we are given two integer N(contains last four digit of aadhaar no) and M(worker’s age).
Some rule are also given if any worker’s age is below 24 then he can’t get vaccinated.
If worker’s age is greater or equal then 24 then we have to check another condition whether worker’s last four digit of aadhar number is power of two or not.
If Last Four digit of aadhaar number is in the power of two then print YES else NO.

SOLUTIONS:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t–)
{
int n, age;
cin >> n >> age;
if (age >= 24 && n != 0)
{
int x = (ceil(log2(n)) == floor(log2(n)));
if (x)
{
cout << “YES” << endl;
}
else
{
cout << “NO” << endl;
}
}
else
{
cout << “NO” << endl;
}
}
return 0;
}

Tester's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t–)
{
int n, age;
cin >> n >> age;
if (age >= 24 && n != 0)
{
int x = (ceil(log2(n)) == floor(log2(n)));
if (x)
{
cout << “YES” << endl;
}
else
{
cout << “NO” << endl;
}
}
else
{
cout << “NO” << endl;
}
}
return 0;
}

Editorialist's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t- -)
{
int n, age;
cin >> n >> age;
if (age >= 24 && n != 0)
{
int x = (ceil(log2(n)) == floor(log2(n)));
if (x)
{
cout << “YES” << endl;
}
else
{
cout << “NO” << endl;
}
}
else
{
cout << “NO” << endl;
}
}
return 0;
}

Pls tell why this is incorrect CodeChef: Practical coding for everyone