bilibiliCXK
V2EX  ›  问与答

华为普工面试题,这道题怎么解

  •  
  •   bilibiliCXK · Apr 27, 2020 · 5570 views
    This topic created in 2381 days ago, the information mentioned may be changed or developed.
    36.请编写一个算法,使得等式成立。

    1 2 3 4 5 6 7 8 = 1024
    25 replies  •  2020-04-29 12:31:24 +08:00
    choudidi
    choudidi
    Apr 27, 2020
    1
    确定是普工?
    cyndra0
    cyndra0
    Apr 27, 2020❤️4
    2
    (1+2+3-4)^(5+6+7-8)=1024
    minami
    minami
    Apr 27, 2020
    3
    DFS 暴力搜就完事了
    stoneabc
    stoneabc
    Apr 27, 2020
    4
    24 点加强版?
    minami
    minami
    Apr 27, 2020
    5
    @choudidi #1 华为校招笔试题就是这样子的。。
    bilibiliCXK
    bilibiliCXK
    OP
    Apr 27, 2020
    6
    @choudidi 是的,华为的普工要求全日制高中以上学历,大专优先录用。所以这类题目比较难
    choudidi
    choudidi
    Apr 27, 2020
    7
    @bilibiliCXK 真棒
    bilibiliCXK
    bilibiliCXK
    OP
    Apr 27, 2020
    8
    @cyndra0
    @choudidi

    对的
    unidentifiedme
    unidentifiedme
    Apr 27, 2020
    9
    没想到搜索之外的方法,不过这个仅限四则运算和括号都有 8*7*4*7*6*4*6*5*4*5*4*4*3*2*4*2*1*4 种可能,brute force 应该是不行,剪剪枝不知道行不行
    Caturra
    Caturra
    Apr 27, 2020❤️1
    10
    1 << (2 + 3/4 + 5/6*7 + 8)
    /是下取整
    cnmllll
    cnmllll
    Apr 27, 2020
    11
    1*2**(3*4+5-6+7-8) 第一时间想到了 2**10=1024 后面的数字往 10 上靠
    gdt
    gdt
    Apr 27, 2020
    12
    2=2 的 1 次方,4=2 的 2 次方,8 等于 2 的 3 次方,1024=2 的 10 次方。两边约去 2 的 6 次方,简化为 3 5 6 7 -> 2 的 4 次方。
    gdt
    gdt
    Apr 27, 2020
    13
    @gdt 简化为 1 3 5 6 7 -> 2 的 4 次方。(1+3)*(5+6-7)=2 的 4 次方。
    wszgrcy
    wszgrcy
    Apr 27, 2020 via Android
    14
    回溯?
    ssdrtt
    ssdrtt
    Apr 27, 2020
    15
    ((1+2*3+4)*(5+6)+7)*8
    yiqunz
    yiqunz
    Apr 27, 2020
    16
    看对 1024 敏不敏感,转 2^10 即可
    ppyzzz
    ppyzzz
    Apr 27, 2020
    17
    华为啥类型的普工?俺不懂,但是感觉不是很难的样子
    bilibiliCXK
    bilibiliCXK
    OP
    Apr 27, 2020❤️1
    18
    @ppyzzz 深圳松山湖。工厂流水线
    bilibiliCXK
    bilibiliCXK
    OP
    Apr 27, 2020
    19
    华为可不是像富士康那样好进,富士康小学文化都可以进,华为最低学历高中,没点真材实料普工都干不了
    iVeego
    iVeego
    Apr 27, 2020
    20
    @bilibiliCXK #18 松山湖不是在东莞嘛
    rrZ2C
    rrZ2C
    Apr 27, 2020
    21
    binxin
    binxin
    Apr 27, 2020
    22
    1*2*(3-(4-(5*(6+7))))*8
    binxin
    binxin
    Apr 27, 2020
    23
    @unidentifiedme 用后置表达式就可以不用括号了,总共有 117 种方法,搜索 14557317 次,也许还可以剪枝,不过目前卡在怎么把后置表达式换成人眼能看懂的中置。
    hublot
    hublot
    Apr 27, 2020
    24
    1 * 2^((3 * 4) + (5 - 6 + 7 - 8)) =
    1 * 2^(12 - 2) =
    2^10
    unidentifiedme
    unidentifiedme
    Apr 29, 2020
    25
    @binxin 括号并不影响搜索空间的大小
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4997 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 62ms · UTC 03:46 · PVG 11:46 · LAX 19:46 · JFK 22:46
    ♥ Do have faith in what you're doing.