mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
48 lines
1.4 KiB
HTML
48 lines
1.4 KiB
HTML
<p>给你一个整数数组 <code>nums</code> ,返回其中 <strong>按位与三元组</strong> 的数目。</p>
|
||
|
||
<p><strong>按位与三元组</strong> 是由下标 <code>(i, j, k)</code> 组成的三元组,并满足下述全部条件:</p>
|
||
|
||
<ul>
|
||
<li><code>0 <= i < nums.length</code></li>
|
||
<li><code>0 <= j < nums.length</code></li>
|
||
<li><code>0 <= k < nums.length</code></li>
|
||
<li><code>nums[i] & nums[j] & nums[k] == 0</code> ,其中 <code>&</code> 表示按位与运算符。</li>
|
||
</ul>
|
||
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [2,1,3]
|
||
<strong>输出:</strong>12
|
||
<strong>解释:</strong>可以选出如下 i, j, k 三元组:
|
||
(i=0, j=0, k=1) : 2 & 2 & 1
|
||
(i=0, j=1, k=0) : 2 & 1 & 2
|
||
(i=0, j=1, k=1) : 2 & 1 & 1
|
||
(i=0, j=1, k=2) : 2 & 1 & 3
|
||
(i=0, j=2, k=1) : 2 & 3 & 1
|
||
(i=1, j=0, k=0) : 1 & 2 & 2
|
||
(i=1, j=0, k=1) : 1 & 2 & 1
|
||
(i=1, j=0, k=2) : 1 & 2 & 3
|
||
(i=1, j=1, k=0) : 1 & 1 & 2
|
||
(i=1, j=2, k=0) : 1 & 3 & 2
|
||
(i=2, j=0, k=1) : 3 & 2 & 1
|
||
(i=2, j=1, k=0) : 3 & 1 & 2
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [0,0,0]
|
||
<strong>输出:</strong>27
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 1000</code></li>
|
||
<li><code>0 <= nums[i] < 2<sup>16</sup></code></li>
|
||
</ul>
|