mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										30
									
								
								算法题(国外版)/count-equal-and-divisible-pairs-in-an-array.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								算法题(国外版)/count-equal-and-divisible-pairs-in-an-array.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
Given a <strong>0-indexed</strong> integer array <code>nums</code> of length <code>n</code> and an integer <code>k</code>, return <em>the <strong>number of pairs</strong></em> <code>(i, j)</code> <em>where</em> <code>0 <= i < j < n</code>, <em>such that</em> <code>nums[i] == nums[j]</code> <em>and</em> <code>(i * j)</code> <em>is divisible by</em> <code>k</code>.
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [3,1,2,2,2,1,3], k = 2
 | 
			
		||||
<strong>Output:</strong> 4
 | 
			
		||||
<strong>Explanation:</strong>
 | 
			
		||||
There are 4 pairs that meet all the requirements:
 | 
			
		||||
- nums[0] == nums[6], and 0 * 6 == 0, which is divisible by 2.
 | 
			
		||||
- nums[2] == nums[3], and 2 * 3 == 6, which is divisible by 2.
 | 
			
		||||
- nums[2] == nums[4], and 2 * 4 == 8, which is divisible by 2.
 | 
			
		||||
- nums[3] == nums[4], and 3 * 4 == 12, which is divisible by 2.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,2,3,4], k = 1
 | 
			
		||||
<strong>Output:</strong> 0
 | 
			
		||||
<strong>Explanation:</strong> Since no value in nums is repeated, there are no pairs (i,j) that meet all the requirements.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= nums.length <= 100</code></li>
 | 
			
		||||
	<li><code>1 <= nums[i], k <= 100</code></li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user