avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • Resume
  • Archives
  • Categories
  • Photos
  • Music



{{ date }}

{{ time }}

avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • 主页
  • Resume
  • Archives
  • Categories
  • Photos
  • Music

1250. examine「Good array」 One question daily

  2024-01-01        
字数统计: 226字   |   阅读时长: 1min

topic:

2023-02-15 (1).png
1250. examine「Good array」.md

Thought:

  1. @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

  2. @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:

PT_zhen
1
2
3
class Solution:
def isGoodArray(self, nums: List[int]) -> bool:
return True if math.gcd(*nums) == 1 else False
ylb
1
2
3
class Solution:
def isGoodArray(self, nums: List[int]) -> bool:
return reduce(gcd, nums) == 1
  • Python
  • answer
  • math

扫一扫,分享到微信

微信分享二维码
1233Delete the subfolder folder One question daily
1237. Find out the positive combination of the given square One question daily
目录
  1. 1. topic:
  2. 2. Thought:
  3. 3. Code:

150 篇 | 131.7k
次 | 人
这里自动载入天数这里自动载入时分秒
2022-2025 loong loong | 新南威尔士龙龙号