mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
|
<p>给你三个正整数 <code>a</code>、<code>b</code> 和 <code>c</code>。</p>
|
|||
|
|
|||
|
<p>你可以对 <code>a</code> 和 <code>b</code> 的二进制表示进行位翻转操作,返回能够使按位或运算 <code>a</code> OR <code>b</code> == <code>c</code> 成立的最小翻转次数。</p>
|
|||
|
|
|||
|
<p>「位翻转操作」是指将一个数的二进制表示任何单个位上的 1 变成 0 或者 0 变成 1 。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/01/11/sample_3_1676.png" style="height: 87px; width: 260px;"></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>a = 2, b = 6, c = 5
|
|||
|
<strong>输出:</strong>3
|
|||
|
<strong>解释:</strong>翻转后 a = 1 , b = 4 , c = 5 使得 <code>a</code> OR <code>b</code> == <code>c</code></pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>a = 4, b = 2, c = 7
|
|||
|
<strong>输出:</strong>1
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 3:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>a = 1, b = 2, c = 3
|
|||
|
<strong>输出:</strong>0
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>1 <= a <= 10^9</code></li>
|
|||
|
<li><code>1 <= b <= 10^9</code></li>
|
|||
|
<li><code>1 <= c <= 10^9</code></li>
|
|||
|
</ul>
|