Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize currency combination with Java

Shulou Source: shulou.com Published: 2022-06-01 23:07:52 09月21日 Update

This article focuses on "how to use Java to achieve currency combination", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use Java to achieve currency combination"!

I will give you six banknotes with denominations of 1, 5, 10, 20, 50 and 100 yuan. Assuming that the number of each currency is enough, write a program to find the number of different combinations that make up N yuan (N is a non-negative integer of 010000 yuan). Analyze first

1: suppose the sum of 100 and 50 coins is num, and num = 0pr 50, 100 pr 150, 50 * (Nmax 50)

The combinatorial number is Z1 (100x + 50y = the number of nonnegative integer solutions of num)

There are k sheets at 2: 20, karma 0pm 1pm 2pm 3pm. , (N-num) / 20

3: so the sum of these coins is v1andv5andv10 = N-num-20 * k.

The number of combinations is Z2 (10x+5y

Tags: Combination number integer currency content answer result learning loop different practical deeper arithmetic sequence no interest memory variable just practicality essence Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft OPPO Reno Apple Xiaomi