Codechef Algo Solution

Problem

Given the rating R of a person, tell which division he belongs to. The rating range for each division are given below:

  • Division 12000 \le Rating.

  • Division 21600 \le Rating \lt 2000.

  • Division 3: Rating \lt 1600.

Input Format

  • The first line of the input contains T - the number of test cases. Then the test cases follow.
  • Each testcase contains a single line of input, which contains a single integer R.

Output Format

For each test case, output on a single line the answer: 1 if the person belongs to Division 12 if the person belongs to Division 2, and 3 if the person belongs to Division 3.

Constraints

  • 1 \leq T \leq 1000
  • 1000 \leq R \leq 4500

Sample 1:

Input
Output
3
1500
4000
1900
3
1
2

Explanation:

Test case 1: Since the rating of the person lies in the range [1000, 1600), he belongs to Division 3.

Test case 2: Since the rating of the person lies in the range [2000, 4500], he belongs to Division 1.

Test case 3: Since the rating of the person lies in the range [1600, 2000), he belongs to Division 2.





Program :


#include<stdio.h>
        int main ()
        {
           int n,i,a;
           scanf("%d",&n);
           for(i=0;i<n;i++)
           {
               scanf("%d\n",&a);
               if(a>=1000&&a<1600)
                    printf("3\n");
              else if(a>=1600&&a<2000)
                    printf("2\n");
               if(a>=2000&&a<=4500)
                    printf("1\n");
           }

        }

Post a Comment

0 Comments