1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最大异或乘积 [maximum-xor-product].html
2023-12-09 01:16:38 +08:00

43 lines
1.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你三个整数&nbsp;<code>a</code>&nbsp;<code>b</code>&nbsp;&nbsp;<code>n</code>&nbsp;,请你返回&nbsp;<code>(a XOR x) * (b XOR x)</code>&nbsp;&nbsp;<strong>最大值</strong>&nbsp;<code>x</code>&nbsp;需要满足 <code>0 &lt;= x &lt; 2<sup>n</sup></code></p>
<p>由于答案可能会很大,返回它对&nbsp;<code>10<sup>9 </sup>+ 7</code>&nbsp;<strong>取余</strong>&nbsp;后的结果。</p>
<p><strong>注意</strong><code>XOR</code>&nbsp;是按位异或操作。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<b>输入:</b>a = 12, b = 5, n = 4
<b>输出:</b>98
<b>解释:</b>当 x = 2 时,(a XOR x) = 14 且 (b XOR x) = 7 。所以,(a XOR x) * (b XOR x) = 98 。
98 是所有满足 0 &lt;= x &lt; 2<sup>n </sup>中 (a XOR x) * (b XOR x) 的最大值。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<b>输入:</b>a = 6, b = 7 , n = 5
<b>输出:</b>930
<b>解释:</b>当 x = 25 时,(a XOR x) = 31 且 (b XOR x) = 30 。所以,(a XOR x) * (b XOR x) = 930 。
930 是所有满足 0 &lt;= x &lt; 2<sup>n </sup>中 (a XOR x) * (b XOR x) 的最大值。</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<b>输入:</b>a = 1, b = 6, n = 3
<b>输出:</b>12
<b>解释: </b>当 x = 5 时,(a XOR x) = 4 且 (b XOR x) = 3 。所以,(a XOR x) * (b XOR x) = 12 。
12 是所有满足 0 &lt;= x &lt; 2<sup>n </sup>中 (a XOR x) * (b XOR x) 的最大值。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= a, b &lt; 2<sup>50</sup></code></li>
<li><code>0 &lt;= n &lt;= 50</code></li>
</ul>