Static void main (string [] ARGs)
{
Int COUNT = 0;
// A maximum of 100 types of data may consist of 1 RMB
For (int A = 0; A <= 100; A ++)
{
// There are up to 50 possibilities in the case of 2 RMB
For (INT B = 0; B <= 50; B ++)
{
For (int c = 0; C <= 20; C ++)
{
// 10 RMB, up to 10 possibilities
For (int d = 0; D <= 10; D ++)
{
// In the case of 20 yuan, a maximum of 5 possibilities
For (int e = 0; e <= 5; E ++)
{
// 50 RMB, up to 2 possibilities
For (INT f = 0; F <= 2; F ++)
{
If (1 * A + 2 * B + 5 * C + 10 * D + 20 * E + 50 * F) = 100)
{
Count ++;
Console. writeline ("1 * {0} + 2 * {1} + 5 * {2} + 10 * {3} + 20 * {4} + 50 * {5} = 100 ",
A, B, C, D, E, F );
}
}
}
}
}
}
}
Console. writeline ("A total of {0} possible cases", count); // COUNT = 4562
Console. readkey ();
}
Http://topic.csdn.net/u/20081016/14/8e1b21c7-dbc8-40ce-ba93-28c4cac4e461.html
Similar; http://topic.csdn.net/t/20030712/23/2021573.html