某人想将手中的一张面值100元的人民币换成10元、5元、2元和1元面值的票子。要求换正好40张,且每种票子至少一张。问:有几种换法?
#include <stdio.h>
//某人想将手中的一张面值100元的人民币换成10元、5元、2元和1元面值的票子。要求换正好40张,且每种票子至少一张。问:有几种换法?
int main() {
int total=0;
for (int ten=1;ten<=10;ten++)
{
for(int five=1;five<=20;five++)
{
for (int two=1;two<=50;two++)
{
for(int one=1;one<=100;one++)
{
if(ten+five+two+one==40 && ten*10+five*5+two*2+one==100)
{
total=total+1;
}
}
}
}
}
printf("%d",total);
return 0;
}