东方亚洲欧a∨人在线观看|欧美亚洲日韩在线播放|日韩欧美精品一区|久久97AV综合

        999.,車(chē)可用捕獲量x

        發(fā)布時(shí)間:2020-09-07 來(lái)源: 講話發(fā)言 點(diǎn)擊:

         999. 車(chē)的可用捕獲量 在一個(gè) 8 x 8 的棋盤(pán)上,有一個(gè)白色車(chē)(rook)。也可能有空方塊,白色的象(bishop)和黑色的卒(pawn)。它們分別以字符 “R”,“.”,“B” 和 “p” 給出。大寫(xiě)字符表示白棋,小寫(xiě)字符表示黑棋。

         車(chē)按國(guó)際象棋中的規(guī)則移動(dòng):它選擇四個(gè)基本方向中的一個(gè)(北,東,西和南),然后朝那個(gè)方向移動(dòng),直到它選擇停止、到達(dá)棋盤(pán)的邊緣或移動(dòng)到同一方格來(lái)捕獲該方格上顏色相反的卒。另外,車(chē)不能與其他友方(白色)象進(jìn)入同一個(gè)方格。

         返回車(chē)能夠在一次移動(dòng)中捕獲到的卒的數(shù)量。

          示例 1:

        。

          輸入:[[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","R",".",".",".","p"],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]

         輸出:3

         解釋?zhuān)?/p>

         在本例中,車(chē)能夠捕獲所有的卒。

         示例 2:

         :

          輸入:[[".",".",".",".",".",".",".","."],[".","p","p","p","p","p",".","."],[".","p","p","B","p","p",".","."],[".","p","B","R","B","p",".","."],[".","p","p","B","p","p",".","."],[".","p","p","p","p","p",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]

         輸出:0

         解釋?zhuān)?/p>

         象阻止了車(chē)捕獲任何卒。

         示例 3:

        。

          輸入:[[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","p",".",".",".","."],["p","p",".","R",".","p","B","."],[".",".",".",".",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."]]

         輸出:3

         解釋?zhuān)?/p>

         車(chē)可以捕獲位置 b5,d6 和 f5 的卒。

         提示:

         提示:

         1 board.length == board[i].length == 8

         2 board[i][j]

         可以是 "R" , "." , "B"

         或 "p"

         3. 只有一個(gè)格子上存在 board[i][j] == "R"

        相關(guān)熱詞搜索:捕獲量 可用 999

        版權(quán)所有 蒲公英文摘 smilezhuce.com