mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-26 18:20:27 +08:00
72 lines
2.7 KiB
HTML
72 lines
2.7 KiB
HTML
<p>给你一个大小为 <code>m x n</code> 的二维整数数组 <code>grid</code> 和一个整数 <code>k</code> 。</p>
|
||
|
||
<p>你的任务是统计满足以下 <strong>条件</strong> 且从左上格子 <code>(0, 0)</code> 出发到达右下格子 <code>(m - 1, n - 1)</code> 的路径数目:</p>
|
||
|
||
<ul>
|
||
<li>每一步你可以向右或者向下走,也就是如果格子存在的话,可以从格子 <code>(i, j)</code> 走到格子 <code>(i, j + 1)</code> 或者格子 <code>(i + 1, j)</code> 。</li>
|
||
<li>路径上经过的所有数字 <code>XOR</code> 异或值必须 <strong>等于</strong> <code>k</code> 。</li>
|
||
</ul>
|
||
|
||
<p>请你返回满足上述条件的路径总数。</p>
|
||
|
||
<p>由于答案可能很大,请你将答案对 <code>10<sup>9</sup> + 7</code> <strong>取余</strong> 后返回。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong class="example">示例 1:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><span class="example-io"><b>输入:</b>grid = [[2, 1, 5], [7, 10, 0], [12, 6, 4]], k = 11</span></p>
|
||
|
||
<p><span class="example-io"><b>输出:</b>3</span></p>
|
||
|
||
<p><b>解释:</b></p>
|
||
|
||
<p>3 条路径分别为:</p>
|
||
|
||
<ul>
|
||
<li><code>(0, 0) → (1, 0) → (2, 0) → (2, 1) → (2, 2)</code></li>
|
||
<li><code>(0, 0) → (1, 0) → (1, 1) → (1, 2) → (2, 2)</code></li>
|
||
<li><code>(0, 0) → (0, 1) → (1, 1) → (2, 1) → (2, 2)</code></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 2:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><span class="example-io"><b>输入:</b>grid = [[1, 3, 3, 3], [0, 3, 3, 2], [3, 0, 1, 1]], k = 2</span></p>
|
||
|
||
<p><span class="example-io"><b>输出:</b>5</span></p>
|
||
|
||
<p><b>解释:</b></p>
|
||
|
||
<p>5 条路径分别为:</p>
|
||
|
||
<ul>
|
||
<li><code>(0, 0) → (1, 0) → (2, 0) → (2, 1) → (2, 2) → (2, 3)</code></li>
|
||
<li><code>(0, 0) → (1, 0) → (1, 1) → (2, 1) → (2, 2) → (2, 3)</code></li>
|
||
<li><code>(0, 0) → (1, 0) → (1, 1) → (1, 2) → (1, 3) → (2, 3)</code></li>
|
||
<li><code>(0, 0) → (0, 1) → (1, 1) → (1, 2) → (2, 2) → (2, 3)</code></li>
|
||
<li><code>(0, 0) → (0, 1) → (0, 2) → (1, 2) → (2, 2) → (2, 3)</code></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 3:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><span class="example-io"><b>输入:</b>grid = [[1, 1, 1, 2], [3, 0, 3, 2], [3, 0, 2, 2]], k = 10</span></p>
|
||
|
||
<p><span class="example-io"><b>输出:</b>0</span></p>
|
||
</div>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= m == grid.length <= 300</code></li>
|
||
<li><code>1 <= n == grid[r].length <= 300</code></li>
|
||
<li><code>0 <= grid[r][c] < 16</code></li>
|
||
<li><code>0 <= k < 16</code></li>
|
||
</ul>
|