科大讯飞笔试

#include<stdio.h>
#include<string.h>



int main(void)
{
	int a, b, c, d, e, k;

	while (scanf("%d %d %d %d %d", &a, &b, &c, &d, &e) != EOF)
	{
		scanf("%d", &k);

		int cnt = 0, temp = 0, flag = 1, pri = 0;
		while (k != 0)
		{
			if (k > 100)
			{
				if (e > 0)
				{
					pri = 5;
				}
				else if (d > 0)
				{
					pri = 4;
				}
				else if (c > 0)
				{
					pri = 3;
				}
				else if (b > 0)
				{
					pri = 2;
				}
				else if (a > 0)
				{
					pri = 1;
				}
			}
			else if (k >= 50 && k < 100)
			{
				if (d > 0)
				{
					pri = 4;
				}
				else if (c > 0)
				{
					pri = 3;
				}
				else if (b > 0)
				{
					pri = 2;
				}
				else if (a > 0)
				{
					pri = 1;
				}

			}
			else if (k >= 10 && k < 50)
			{
				if (c > 0)
				{
					pri = 3;
				}
				else if (b > 0)
				{
					pri = 2;
				}
				else if (a > 0)
				{
					pri = 1;
				}

			}
			else if (k >= 5 && k < 10)
			{
				if (b > 0)
				{
					pri = 2;
				}
				else if (a > 0)
				{
					pri = 1;
				}
			}
			else
			{
				if (a > 0)
				{
					pri = 1;
				}
			}

			if (k > 100 && e > 0 || pri == 5)
			{
				
				temp = k / 100;
				if (temp <= e)
				{
					k %= 100;
					cnt += temp;
				}
				else
				{
					cnt += e;
					
					k = k - e * 100;
					e = 0;
				}


			}
			else if (k >= 50 && k < 100 && d > 0 || pri == 4)
			{
				temp = k / 50;
				if (temp <= d)
				{
					k %= 50;
					cnt += temp;
				}
				else
				{
					cnt += d;
					
					k = k - d * 50;
					d = 0;
				}


			}
			else if (k >= 10 && k < 50 && c > 0 || pri == 3)
			{

				temp = k / 10;
				if (temp <= c)
				{
					k %= 10;
					cnt += temp;
				}
				else
				{
					cnt += c;
					
					k = k - c * 10;
					c = 0;
				}


			}
			else if (k >= 5 && k < 10 && b > 0 || pri == 2)
			{
				temp = k / 5;
				if (temp <= b)
				{
					k %= 5;
					cnt += temp;
				}
				else
				{
					cnt += b;
					
					k = k - b * 5;
					b = 0;
				}

			}
			else if (k >= 1 && k < 5 && a>0 || pri == 1)
			{

				temp = k;
				if (temp <= a)
				{
					k = 0;
					cnt += temp;
				}
				else
				{
					cnt += a;
					
					k = k - a;
					a = 0;
				}

			}


			if (a == 0 && k != 0)
			{
				cnt = -1;
				break;
			}

		}


		printf("%d\n", cnt);


	}

	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值