Manish has come up with a solution that if we make coins category starting from $1 till the maximum price of item present on Island, then we can purchase any item easily. He added following example to prove his point.
Lets suppose the maximum price of an item is 5$ then we can make coins of {$1, $2, $3, $4, $5} to purchase any item ranging from $1 till $5.
Now Manisha, being a keen observer suggested that we could actually minimize the number of coins required and gave following distribution {$1, $2, $3}. According to him any item can be purchased one time ranging from $1 to $5. Everyone was impressed with both of them.
Your task is to help Manisha come up with minimum number of denominations for any arbitrary max price in Philaland.
Answers
Answer:
According to him any item can be purchased one time ranging from $1 to $5. Everyone was impressed with both of them. Your task is to help Manisha come up with minimum number of denominations for any arbitrary max price in Philaland. First line contains an integer T denoting the number of test cases.Jul 5, 2019
Language using :- Python Programming
Program :-
t=int(input())
if t>=1 and t<=100:
while(t>0):
sum=0
total=0
n=int(input())
if n>=1 and n<=5000:
l=list(range(1,n+1))
for i in l:
if sum!=n+1 and sum<n+1:
sum=sum+i
total=total+1
if sum>n+1 or sum==n:
sum=sum-i
total=total-1
if sum==n+1:
print(total)
break
t=t-1
Input :-
2
10
5
Output :-
4
3
Learn more :
1) Printing all the palindromes formed by a palindrome word.
brainly.in/question/19151384
2) Indentation is must in python. Know more about it at :
brainly.in/question/17731168
3) Write a Python function sumsquare(l) that takes a nonempty list of integers and returns a list [odd,even], where odd is the sum of squares all the odd numbers in l and even is the sum of squares of all the even numbers in l.
brainly.in/question/15473120