mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given an integer array nums, return <em>the number of <strong>AND triples</strong></em>.</p>
 | 
						|
 | 
						|
<p>An <strong>AND triple</strong> is a triple of indices <code>(i, j, k)</code> such that:</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>, where <code>&</code> represents the bitwise-AND operator.</li>
 | 
						|
</ul>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> nums = [2,1,3]
 | 
						|
<strong>Output:</strong> 12
 | 
						|
<strong>Explanation:</strong> We could choose the following i, j, k triples:
 | 
						|
(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 class="example">Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> nums = [0,0,0]
 | 
						|
<strong>Output:</strong> 27
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= nums.length <= 1000</code></li>
 | 
						|
	<li><code>0 <= nums[i] < 2<sup>16</sup></code></li>
 | 
						|
</ul>
 |