Practice problem link Practice
Contest problem link Contest
Author : Abhishek Kumar
Tester : Sandeep Singh
Editorialist : Abhishek Kumar
DIFFICULTY:
CAKEWALK
PREREQUISITES:
If-Else
PROBLEM:
Finding chef rating how much star chef rated is according to given rating pattern.
EXPLANATION:
Simply you have to check the condition but only need to keep in mind about open interval and close interval .
example:- if you encounter ( and ) means that number will not be include . but if you encounter [ or ] means include that number also in rating range.
Example–
[a,b]:- range is from a to b → here a are enclosed by [ and b are enclosed by ] so in range both a and b will be include.
[a,b):- range is from a to b-1 → here a are enclosed by [ and b are enclosed by ) so in range b will not be include.
(a,b):- range is from a-1 to b-1 → here at a are enclosed by ( and b are enclosed by ) so in range both a and b will not be include.
SOLUTIONS:
Setter's Solution
import bisect
li=[1400,1600,1800,2000,2200,2500]
for i in range(int(input())):
v=int(input())
if(v>=0):
print(bisect.bisect_right(li,v)+1)
Tester's Solution
#include <stdio.h>
int main() {
int t;
scanf(“%d”, &t);
while(t--){
int n,ans;
scanf("%d",&n);
if(n<1400)
ans=1;
else if(n<1600)
ans=2;
else if(n<1800)
ans=3;
else if(n<2000)
ans=4;
else if(n<2200)
ans=5;
else if(n<2500)
ans=6;
else
ans=7;
printf("%d\n",ans);
}
return 0;
}
I HOPE YOU WILL LIKE IT
< HAPPY CODING />