• 请不要在回答技术问题时复制粘贴 AI 生成的内容
iXingo
V2EX  ›  程序员

122455 组成六位数字,比 300000 大的自然数有多少

  •  
  •   iXingo ·
    iXingo · Dec 18, 2020 · 2747 views
    This topic created in 1972 days ago, the information mentioned may be changed or developed.
    9 replies    2021-01-06 18:36:34 +08:00
    301
        1
    301  
       Dec 18, 2020 via Android
    有一半
    sirnay
        2
    sirnay  
       Dec 18, 2020
    [554221 545221 455221 552421 525421 542521 452521 524521 425521 552241 525241 522541 542251 452251 524251 425251 522451 422551 554212 545212 455212 552412 525412 542512 452512 524512 425512 554122 545122 455122 551422 515422 541522 451522 514522 415522 552142 525142 551242 515242 521542 512542 542152 452152 524152 425152 541252 451252 514252 415252 521452 512452 421552 412552 552214 525214 522514 552124 525124 551224 515224 521524 512524 522154 521254 512254 542215 452215 524215 425215 522415 422515 542125 452125 524125 425125 541225 451225 514225 415225 521425 512425 421525 412525 522145 521245 512245 422155 421255 412255]
    sirnay
        3
    sirnay  
       Dec 18, 2020
    func permuteUnique(nums []int) (ans int) {
    sort.Ints(nums)
    n := len(nums)
    perm := []int{}
    vis := make([]bool, n)

    r := make([]int, 0)
    var backtrack func(int)
    backtrack = func(idx int) {
    if idx == n {
    tmp := make([]int, len(perm))
    copy(tmp, perm)

    sum := 0
    for i := 0; i < len(perm); i++ {
    sum += tmp[i] * int(math.Pow10(i))
    }

    if sum > 300000 {
    ans++
    r = append(r, sum)
    }

    return
    }
    for i, v := range nums {
    //
    if vis[i] || i > 0 && !vis[i-1] && v == nums[i-1] {
    continue
    }
    perm = append(perm, v)
    vis[i] = true
    backtrack(idx + 1)
    vis[i] = false
    perm = perm[:len(perm)-1]
    }
    }
    backtrack(0)
    return
    }
    sirnay
        4
    sirnay  
       Dec 18, 2020
    https://leetcode-cn.com/problems/permutations-ii/

    算是这个题目的变形吧。
    Inn0Vat10n
        5
    Inn0Vat10n  
       Dec 18, 2020   ❤️ 1
    A(6,6)/2/2/2=90
    dustinth
        6
    dustinth  
       Dec 18, 2020
    C(3, 1) * C(5, 5) / 4 = 90
    ArtsXiaoLu
        7
    ArtsXiaoLu  
       Dec 18, 2020
    http://www.ab126.com/shuxue/1641.html
    这问题找李永乐回答合适
    tribute
        8
    tribute  
       Dec 18, 2020
    C(3,1)*P(5,5)/(P(2,2)^2)
    iXingo
        9
    iXingo  
    OP
       Jan 6, 2021
    谢谢诸位老铁
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5622 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 08:27 · PVG 16:27 · LAX 01:27 · JFK 04:27
    ♥ Do have faith in what you're doing.