1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/或运算的最小翻转次数 [minimum-flips-to-make-a-or-b-equal-to-c].html

38 lines
1.3 KiB
HTML
Raw Normal View History

2022-03-27 20:37:52 +08:00
<p>给你三个正整数&nbsp;<code>a</code><code>b</code><code>c</code></p>
<p>你可以对 <code>a</code><code>b</code>&nbsp;的二进制表示进行位翻转操作,返回能够使按位或运算&nbsp; &nbsp;<code>a</code> OR <code>b</code> == <code>c</code>&nbsp;&nbsp;成立的最小翻转次数。</p>
<p>「位翻转操作」是指将一个数的二进制表示任何单个位上的 1 变成 0 或者 0 变成 1 。</p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= a &lt;= 10^9</code></li>
<li><code>1 &lt;= b&nbsp;&lt;= 10^9</code></li>
<li><code>1 &lt;= c&nbsp;&lt;= 10^9</code></li>
</ul>