hdu1085!【数学】

Problem Description

Given some Chinese Coins (硬币) (three kinds-- 1, 2, 5), and their number is num_1, num_2 and num_5 respectively, please output the minimum value that you cannot pay with given coins

Input
Input contains multiple test cases. Each test case contains 3 positive integers num_1, num_2 and num_5 (0<=num_i<=1000). A test case containing 0 0 0 terminates the input and this test case is not to be processed.
 
Output
Output the minimum positive value that one cannot pay with given coins, one line for one case.
 
Sample Input
   
   
   
   
1 1 3 0 0 0
 
Sample Output
   
   
   
   
4
 
Author
lcy
#include<stdio.h>
int main()
{
	int i, j, k, a, b, c;
	while(scanf("%d%d%d", &a, &b, &c) != EOF && (a || b || c))
	{
		int len = 0;
		if(a == 0)
		len = 0;
		else 
		{
			len = a + 2 * b;
			if( len >= 4)
			len += 5*c;
		}
		printf("%d\n", len+1);//+1是它永远无法弥补的 
	}
	return 0;
}

题意:给任意几个面值1,2,5的硬币,算出它所不能的到的最小和。
这题往简单了想就简单,往复杂了想就复杂。
虽然代码短,不过很有意思的。。。。 

你可能感兴趣的:(c)