_ap_ufes{"success":true,"siteUrl":"techblix.com","urls":{"Home":"http://techblix.com","Category":"http://techblix.com/category/3g-4g-plans/","Archive":"http://techblix.com/2017/02/","Post":"http://techblix.com/use-reliance-jio-4g-sim-3g-devices-tricks-proven-work-jio-4g-sim/","Page":"http://techblix.com/guestsponsored-posts/","Attachment":"http://techblix.com/use-reliance-jio-4g-sim-3g-devices-tricks-proven-work-jio-4g-sim/j43g-10/","Nav_menu_item":"http://techblix.com/indianist-2/","Wpcf7_contact_form":"http://techblix.com/?post_type=wpcf7_contact_form&p=5633","Wysijap":"http://techblix.com/?wysijap=subscriptions","Feedback":"http://techblix.com/?post_type=feedback&p=7770","Safecss":"http://techblix.com/?safecss=safecss"}}_ap_ufee
Breaking News

Solved Previous years TCS CodeVita questions – Milk Man and His Bottles

Previous year TCS CodeVita Questions- 2015

previous years TCS CodeVita questions with solutions

 

Problem : Milk Man and His Bottles

A Milkman serves milk in packaged bottles of varied sizes. The possible size of the bottles are {1, 5, 7 and 10} litres. He wants to supply desired quantity using as less bottles as possible irrespective of the size. Your objective is to help him find the minimum number of bottles required to supply the given demand of milk.

 

Input Format: 

First line contains number of test cases N
Next N lines, each contain a positive integer Li which corresponds
to the demand of milk.

 

Output Format:

For each input Li, print the minimum number of bottles required to
fulfill the demand

 

Constraints:

1<= N <= 1000

Li> 0

1<= i <= N

Sample Input and Output

SNo. Input Output
1 2

17

65

2

7

 

Explanation:

Number of test cases is 2

  1. In first test case, demand of
    milk is 17 litres which can be supplied using minimum of 2 bottles as
    follows

    • 1 x 10 litres and
    • 1 x 7 litres
  2. In second test case, demand of
    milk is 65 litres which can be supplied using minimum of 7 bottles as
    follows

    • 6 x 10 litres and
    • 1 x 5 litres

 

Solved Previous years TCS CodeVita questions – Milk Man and His Bottles

Sample Solution in C Programming:

#include<stdio.h>
int main()
{
 int b,n,l;
 scanf("%d",&n);
 while(n>0)
 {
 scanf("%d",&l);
 b=0;
 while(l>0)
 {
 b++;
 if(l>=10)
  l=l-10;
 else if(l>=7)
  l=l-7;
 else if(l>=5)
  l=l-5;
 else
  l=l-1;
 }
 printf("%d\n",b);
 n--;
 }
 return 0;
}
//validate the constraints too
** check other solved codevita questions

Check Also

reliance jio logo

How to use Reliance Jio 4G SIM on 3G devices

Use Jio 4G SIM on 3G devices – 100% tested The main issue with Reliance Jio …

Leave a Reply

error: Right Click is Disabled !!