topic:
Thought:
@PT, PT_ZhenSolution of classmates,Next is his solution:
If there is no big convention,,Then there must be one time。
If two numbers can be made up directly1if,Then other numbers can also be added and subtracted by addition and subtraction1get1.The major convention in a set depends on the largest number of the smallest between the two in this set[10000, 3, 4], 10000 + 9999 * (3 - 4) = 1
@ylb, Pei Shu theorem:We can first consider choosing two numbers,If the selected number is aaa and bbb,So根据topic的要求,We need to be satisfied a×x+b×y=1a \times x + b \times y = 1a×x+b×y=1,in xxx and yyy Any integer。
根据Pei Shu theorem,Can be known,if a and b Mutual quality,Then there must be solution。In fact,Pei Shu theorem也可以推广到多个数的情况,即if a1,a2,⋯,ai
Mutual quality,So a1×x1+a2×x2+⋯+ai×xi=1There must be solution,in x1,x2,⋯,xi Any integer。
Code:
1 | class Solution: |
1 | class Solution: |