MEENA_002 Editorial

PROBLEM LINK:

Practice

Author: Yogesh Deolalkar
Tester: Riddhidh Lichade
Editorialist: Prathamesh Sogale

DIFFICULTY:

CAKEWALK, EASY

PREREQUISITES:

Math

PROBLEM:

There are n houses in a village named Lonere. A Corona pandemic broke out in the village and people are asked to not come out of their houses to avoid further spread. Meena is the head of this village. He suspects that some people might not follow his rules so he comes out with a plan. Meena decides to construct k rivers of infinite length such that any two houses are isolated from each other. Two houses being isolated means you cannot go from one house to another without crossing a river.

Two or more rivers can intersect at a point but a river cannot intersect itself. The rivers need not be necessarily straight (they can be curved any number of times)

He wants to be as efficient as possible, so he comes to you for help. Can you find the minimum possible k, such that k rivers can isolate n houses in the above stated manner.

Note that the houses do not form any kind of order, they are arbitrarily placed in the village and the rivers need not be necessarily straight (they can be curved any number of times).

Setter's Solution

Scanner sc=new Scanner(System.in);
int t = sc.nextInt();
while(t–>0){
int n = sc.nextInt();
int ans = 2;
if(n==1) ans = 0;
else if(n==2) ans = 1;
System.out.println(ans);
}

Tester's Solution

t=int(input())
for _ in range(t):
h=int(input())
if(h==2):
print(‘1’)
elif(h>=3):
print(‘2’)