Answer to Question #232975 in C for SHWETA

Question #232975
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.

Constraints

1 <= N <= 10000 1 <= Li <= N

Output Format

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

Sample Input 0

2
17 65
Sample Output 0

2 7
1
Expert's answer
2021-09-03T14:05:43-0400
#include<stdio.h>




int main(){
	int N,i;
	int bottles[1000];


	scanf("%d",&N);
	for (i = 0; i < N; i++) {
		int milk;
		scanf("%d",&milk);
		bottles[i] = 0;


		bottles[i] += milk / 10;
		milk %= 10;


		bottles[i] += milk / 7;
		milk %= 7;


		bottles[i] += milk / 5;
		milk %= 5;


		bottles[i] += milk;
	}


	for (i = 0; i < N; i++) {
		printf("%d ",bottles[i]);
	}
	scanf("%d",&N);


	return 0;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS