游客 Signup | Login
中文 | En

2915 - 人民币兑换

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

Input

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

Output

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

Examples

Input

1 40

Output

34

Solution 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;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题