Making Friends

Byang is going to join a new school. His new class has N students. Each of the students are identifi…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

This question is poorly worded. It is not clear whether N is the class size before or after Byang has joined the class.

Also, if you were to join a new school and try this method, I would be willing to bet that you would make precisely zero friends; there is a big leap between “Byang plans to make friends…” and “count how many friends he will make”. This requires clarification, such as “Assuming Byang is successful in making friends with everyone he wants to…”.

the entire math is not coded properly like what
I have to divide the input number of N by 2 3 5 or what

The problem is not described properly but the code is right … you have to count the divisors of N … and the number of divisors is the number of friends he will make… hope you’d understand…
Happy Coding !

According to the problem, if the number of students be 6 then Byang’s roll number should be 7 and in that case the output should be 1 since only 1 is divisor of 7 !!!

TL;DR: I think the problem is properly described in the statement. We just have to think a bit to figure it out perfectly.

Everyone who’s confused about the number of students in the class and Byang’s roll number, just think deeply.

The value of N is 6 in the sample case. Firstly, let’s assume 6 is the number of students before Byang joined. So, his roll should be 7 (6+1). But, 7 is a prime number, and it has only one divisor except itself, which is 1. And 1 is certainly smaller than the sample output number, which is 3.
That means, it’s guaranteed that the number of students in the class (N) is including
Byang.

Figuring hidden things out of the problem statement is a part of the solution! :wink:

Why CPU limit exceeded?
n = int(input())

def divisor(n):
for i in range(n):
x = len([i for i in range(1,n-1) if not n % i])
return x
print(divisor(n))