Use 1 yuan, 2 yuan, 5 yuan, 10 yuan, 20 yuan and 50 yuan to make up 100 yuan.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.