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)/可被三整除的偶数的平均值 [average-value-of-even-numbers-that-are-divisible-by-three].html
2022-11-09 15:08:24 +08:00

31 lines
982 B
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>nums</code> ,返回其中可被 <code>3</code> 整除的所有偶数的平均值。</p>
<p>注意:<code>n</code> 个元素的平均值等于 <code>n</code> 个元素 <strong>求和</strong> 再除以 <code>n</code> ,结果 <strong>向下取整</strong> 到最接近的整数。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,3,6,10,12,15]
<strong>输出:</strong>9
<strong>解释:</strong>6 和 12 是可以被 3 整除的偶数。(6 + 12) / 2 = 9 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,4,7,10]
<strong>输出:</strong>0
<strong>解释:</strong>不存在满足题目要求的整数,所以返回 0 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 1000</code></li>
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
</ul>