1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/数的平方等于两数乘积的方法数 [number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers].html
2022-03-29 12:43:11 +08:00

49 lines
1.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你两个整数数组 <code>nums1</code><code>nums2</code> ,请你返回根据以下规则形成的三元组的数目(类型 1 和类型 2 </p>
<ul>
<li>类型 1三元组 <code>(i, j, k)</code> ,如果 <code>nums1[i]<sup>2</sup>&nbsp;== nums2[j] * nums2[k]</code> 其中 <code>0 &lt;= i &lt; nums1.length</code><code>0 &lt;= j &lt; k &lt; nums2.length</code></li>
<li>类型 2三元组 <code>(i, j, k)</code> ,如果 <code>nums2[i]<sup>2</sup>&nbsp;== nums1[j] * nums1[k]</code> 其中 <code>0 &lt;= i &lt; nums2.length</code><code>0 &lt;= j &lt; k &lt; nums1.length</code></li>
</ul>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums1 = [7,4], nums2 = [5,2,8,9]
<strong>输出:</strong>1
<strong>解释:</strong>类型 1(1,1,2), nums1[1]^2 = nums2[1] * nums2[2] (4^2 = 2 * 8)</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums1 = [1,1], nums2 = [1,1,1]
<strong>输出:</strong>9
<strong>解释:</strong>所有三元组都符合题目要求,因为 1^2 = 1 * 1
类型 1(0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2), nums1[i]^2 = nums2[j] * nums2[k]
类型 2(0,0,1), (1,0,1), (2,0,1), nums2[i]^2 = nums1[j] * nums1[k]
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>nums1 = [7,7,8,3], nums2 = [1,2,9,7]
<strong>输出:</strong>2
<strong>解释:</strong>有两个符合题目要求的三元组
类型 1(3,0,2), nums1[3]^2 = nums2[0] * nums2[2]
类型 2(3,0,1), nums2[3]^2 = nums1[0] * nums1[1]
</pre>
<p><strong>示例 4</strong></p>
<pre><strong>输入:</strong>nums1 = [4,7,9,11,23], nums2 = [3,5,1024,12,18]
<strong>输出:</strong>0
<strong>解释:</strong>不存在符合题目要求的三元组
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums1.length, nums2.length &lt;= 1000</code></li>
<li><code>1 &lt;= nums1[i], nums2[i] &lt;= 10^5</code></li>
</ul>