2915 - 人民币兑换

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

小智想将手中N张面值100元的人民币换成10元、5元、2元和1元面值的钱。要求正好换M张小面值人民币,且每种面值至少一张。问:有几种换法?

题目输入

一行:整数n和m,分别代表有n张面值100元的人民币和换成m张小面值。1<=n<=10,40<=m<=100

题目输出

一行:一个代表几种换法的整数,如果不能兑换,则输出No

输入/输出样例

输入格式

1 40

输出格式

34

C++解答

#include<cstdio>
#include<cstring>
using namespace std;

int total=0;
int zhao(int a,int b)
{
	int shi=100/10;
	int wu=100/5;
	int er=100/2;
	int yi=100/1;
	int zhong=100*a;
	for(int x=1;x<=shi;++x)
	  for(int j=1;j<=wu;++j)
	    for(int z=1;z<=er;++z)
	      for(int y=1;y<=yi;++y)
	      if(10*x+5*j+2*z+1*y==zhong&&x+j+z+y==b)
	       ++total;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	zhao(n,m);
	if(total!=0)
	printf("%d",total);
	else
	printf("No");
	return 0;
}