Programming of pirated gold coins

The title explains that when there are only two people, number four can get everything. So when there are only three people, as long as the third gives him some benefits, the fifth will support him, and the fourth will definitely oppose it. So when there are only four people, No.4 has only a little support. With the support of No.4, you can pass, and everyone else is not good. So at the beginning, No.3 and No.5 will support it as long as they get a little benefit. So if gold coins are inseparable, you can have 98, 3 and 5, which are 1 respectively.

The above is a natural language. If you use a programming language, obviously, you can't use reasoning. It can only be exhaustive, and recursive functions can be used. The idea is this:

Premise: 1. To others is 1 or 0 yuan (the reason is omitted). 2. There is a function find(a), a), where a stands for remainder. What are the advantages of people who are used to judge the number of surplus people and propose distribution plans? Here is the search code:

Private find(a) is an integer.

Dim b is an integer

K(a)= 1' I will support myself.

B=0' Number of opponents

If a=5, then

find= 100

other

For i= 1 to 4

If a+I <; Then =5

If you find (a+i)> 1 and (I mod 2 = 1) S to oppose you unconditionally, you can get more benefits if I am an odd number.

b=b+ 1

k(a-i)=0

If ... it will be over.

If ... it will be over.

Next, I

find= 100-b

If a= 1

Print "Get it yourself:"

Print 100-b

Print "Other people who get 1 yuan:"

For i=2 to 5

If k(i)= 1

Print I

If ... it will be over.

Next, I

If ... it will be over.

I haven't tried it. There should be a problem. .