Dr. Vishnu is opening a new world class hospital in a small town designed to be the first preference of the patients in the city. Hospital has N rooms of two types – with TV and without TV, with daily rates of R1 and R2 respectively.
However, from his experience Dr. Vishnu knows that the number of patients is not constant throughout the year, instead it follows a pattern. The number of patients on any given day of the year is given by the following formula –
(6-M)^2 + |D-15| ,
where M is the number of month (1 for jan, 2 for feb …12 for dec) and D is the date (1,2…31).
All patients prefer without TV rooms as they are cheaper, but will opt for with TV rooms only if without TV rooms are not available. Hospital has a revenue target for the first year of operation. Given this target and the values of N, R1 and R2 you need to identify the number of TVs the hospital should buy so that it meets the revenue target. Assume the Hospital opens on 1st Jan and year is a non-leap year.
Constraints
Hospital opens on 1st Jan in an ordinary year
5 <= Number of rooms <= 100
500 <= Room Rates <= 5000
0 <= Target revenue < 90000000
Input Format
First line provides an integer N that denotes the number of rooms in the hospital
Second line provides two space-delimited integers that denote the rates of rooms with TV (R1) and without TV (R2) respectively
Third line provides the revenue target
Output
Minimum number of TVs the hospital needs to buy to meet its revenue target. If it cannot achieve its target, print the total number of rooms in the hospital.
Test Case
Example-1 :
Input
20
1500 1000
7000000
Output
14
Explanation
Using the formula, number of patients on 1st Jan will be 39, on 2nd Jan will be 38 and so on. Considering there are only twenty rooms and rates of both type of rooms are 1500 and 1000 respectively, we will need 14 TV sets to get revenue of 7119500. With 13 TV sets Total revenue will be less than 7000000
Example-2 :
Input
10
1000 1500
10000000
Output
10
Explanation
In the above example, the target will not be achieved, even by equipping all the rooms with TV. Hence, the answer is 10 i.e. total number of rooms in the hospital.
CODE
n=int(input())
num1,num2=map(int,input().split())
est=int(input())
res1,res2=[],[]
mon,fin=0,0
month=[31,28,31,30,31,30,31,31,30,31,30,31]
for j in range(len(month)):
for k in range(month,month[j]+1):
res1.append((6-(j+1))**2+abs(k-15))
res2.append(res1)
res1=[]
for i in range(n+1):
for j in res2:
for k in j:
if(k>=n):
t=n-i
mon=mon+(i*num1+t*num2)
else:
h=n-i
t=k-h
if(t<=0):
mon=mon+(k*num2)
else:
mon=mon+(t*num1+h*num2)
fin=fin+mon
mon=0
if(fin>=est):
print(i)
break
else:
fin=0
else:
print(n)
I didn’t understand the question …can anyone explain?
Send me the code plz
yeah i can explain and also give u solution but its not possible for me to explain it in comment section
Can you mail me the code ,i will try to understant it
could someone please post the answer
can you please say the code for me i didnt understand the question
can you mail me the code please…
Bro can u mail me a solution of this ques?
can u post me the code for this question please..
Can you mail me the code
can you please mail me the solution
could some one post television sets answer
i coudn,t understand the question , but from input, output and explanation we can get answers like this
#include
#include
using namespace std;
inline int func(int j)
{
if(j>n;
int r1,r2;//r1–>with tv,r2–>without tv
cin>>r1>>r2;
int rev;//target revenue
cin>>rev;
if(n*r1*365<rev)
cout<rev)
{
n-=1;
}
cout<<n+2;
}
}
The code written above will give you error
Plase check the identation carefully
I have resolved the error:
n=int(input())
num1,num2=map(int,input().split())
est=int(input())
res1,res2=[],[]
mon,fin=0,0
month=[31,28,31,30,31,30,31,31,30,31,30,31]
for j in range(len(month)):
for k in range(1,month[j]+1):
res1.append((6-(j+1))**2+abs(k-15))
res2.append(res1)
res1=[]
for i in range(n+1):
for j in res2:
for k in j:
if(k>=n):
t=n-i
mon=mon+(i*num1+t*num2)
else:
h=n-i
t=k-h
if(t=est):
print(i)
break
else:
fin=0
else:
print(n)
The code written above will give you an error
In first nested for loop use 1 ranther than ‘month’ in range function
for k in range(1,month[j]+1):
res1.append((6-(j+1))**2+abs(k-15))
res2.append(res1)
res1=[]
n=int(input())
r1,r2=map(int,input().split())
target=int(input())
nr1=n
nr2=0
s=0
flag=0
lst=[31,28,31,30,31,30,31,31,30,31,30,31]
while(flag==0):
for m in range(12):
for d in range(lst[m]):
p=(5-m)**2 + abs(d-14)
if p=nr2:
c=(nr1*r1)+(nr2*r2)
s=s+c
elif(p-nr1)=target):
print(nr2)
print(s)
flag+=1
elif(s<target and nr2==n):
print(n)
flag+=1
elif(s<target and nr2<n):
nr1-=1
nr2+=1
s=0
Output:-
10
1000 1500
10000000
10