Answered Questions

  • 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,...

    t3chn0tr0n

    • Jun 26th, 2019

    Here is a take in Python. Hope this helps. "python def get_bottles(demand): l = [] bottles = [1, 5, 7, 10] for b in bottles: if demand % b is 0: ...

    lavanya

    • Jul 19th, 2016

    Code
    1. #include<stdio.h>
    2. int main()
    3. {
    4.  int b,n,l;
    5.  scanf("%d",&n);
    6.  while(n>0)
    7.  {
    8.  scanf("%d",&l);
    9.  b=0;
    10.  while(l>0)
    11.  {
    12.  b++;
    13.  if(l>=10)
    14.   l=l-10;
    15.  else if(l>=7)
    16.   l=l-7;
    17.  else if(l>=5)
    18.   l=l-5;
    19.  else
    20.   l=l-1;
    21.  }
    22.  printf("%d
    23. ",b);
    24.  n--;
    25.  }
    26.  return 0;
    27. }