Okk @bal_95 , its my mistake I didn’t deep dive into your code and just look into
import permutation
but still I was just trying to make it sense to you and nothing more than that. In my solution (which passed the public and private testcase) I simply followed these following steps:
loop from n1 to n2 and put all the primes into a separate list say p1.
used a O(n^2) loop to form all the combinations required and at the same time checked whether the combination is a prime number or not? If yes, put into another prime list say p2
find out the minimum and maximum out of list p2
used them as a and b of fibonacci series and find the kth element where k is the size of p2.
anyone who solved problem D? , I was getting a slight difference in calculated revenue also in the problem when number of patients are greater than total number of rooms was not defined.
@shivam_js For problem D take into account the following observations:
For the year:-
Before august-
odd months have 31 days and even months have 30 days except February it has 28 days(non-leap year).
August onwards-
odd months have 30 days and even months have 31 days.
For calculating revenue for each day:-
There are 3 conditions if(no. of patients > = no. of rooms)//all rooms will be accquired revenue+=(no. of tv rooms * cost of tv rooms) + (no. of non-tv rooms * cost of non-tv rooms)
else if(no. of patients < no. of rooms && no. of patients <= no. of non-tv rooms) //in this the patients will acquire only non-tv rooms revenue+=(no. of patients * cost of non-tv rooms)
else if(no. of patients < no of rooms && no. of patients > no. of non-tv rooms) //in this all non-tv rooms will be acquired and remaining patients will acquire tv rooms //remaining patients=no. of patients - no. of non-tv rooms revenue+=(no. of non-tv rooms * cost of non-tv rooms) + (remaining patients * cost of tv rooms)
@akashdileep Can you please review this function i made to calculate the revenue
def check(tvrooms,totalrooms,r1,r2):
revenue=0
month=[31,28,31,30,31,30,31,31,30,31,30,31]
nontvrooms=totalrooms-tvrooms
for i in range(1,13):
for j in range(1,month[i-1]+1):
people=((6-i)**2)+abs(j-15)
print(tvrooms,nontvrooms)
if people>=totalrooms:
revenue+=(tvrooms*r1)+(nontvrooms*r2)
else:
if people<=nontvrooms:
revenue+=nontvrooms*r2
else:
revenue+=((people-nontvrooms)*r1)+(nontvrooms*r2)
return revenue
cases = int(input())
for i in range(1, cases + 1):
value = int(input())
coincount = 0
while value >= 1:
value = value // 2
coincount = coincount + 1
print(coincount)