[科大国创杯小学组 2025] 方差

Luogu
IDLGB4321
Time1000ms
Memory512MB
DifficultyP2
模拟2025科创活动小学活动科大国创杯
小可可最近学习了方差的定义。 现在有一个长度为 $n$ 的序列 $a$,小可可希望你求出这个序列的方差。形式化的,即让你求 $\sigma = \frac{(a_1 - \overline{a})^2 + (a_2 - \overline{a})^2 + \cdots + (a_n - \overline{a})^2}{n}$,其中 $\overline{a}$ 表示 $a$ 序列的平均数,即为 $\frac{a_1 + a_2 + \cdots + a_n}{n}$,保证运算过程中所有结果为整数。 ## Input 第一行一个整数 $n$,表示序列长度。 第二行 $n$ 个整数,第 $i$ 个整数表示 $a_i$。 ## Output 一行一个整数,表示 $a$ 序列的方差。 [samples] ## Background Subtask 0 为民间数据,Subtask 1 为官方数据。 ## Note ### 约定和数据范围 - 数据点 $1$,$n = 1$,$1 \leq a_i \leq 100$。 - 数据点 $2 \sim 5$,$1 \leq n \leq 2 \times 10^3$,$1 \leq a_i \leq 2 \times 10^5$。 - 数据点 $6 \sim 10$,$1 \leq n \leq 10^5$,$1 \leq a_i \leq 10^7$。
Samples
Input #1
3
3 3 6
Output #1
2
API Response (JSON)
{
  "problem": {
    "name": "[科大国创杯小学组 2025] 方差",
    "description": {
      "content": "小可可最近学习了方差的定义。 现在有一个长度为 $n$ 的序列 $a$,小可可希望你求出这个序列的方差。形式化的,即让你求 $\\sigma = \\frac{(a_1 - \\overline{a})^2 + (a_2 - \\overline{a})^2 + \\cdots + (a_n - \\overline{a})^2}{n}$,其中 $\\overline{a}$ 表示 $a$ 序列的平均数,即为",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB4321"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "小可可最近学习了方差的定义。\n\n现在有一个长度为 $n$ 的序列 $a$,小可可希望你求出这个序列的方差。形式化的,即让你求 $\\sigma = \\frac{(a_1 - \\overline{a})^2 + (a_2 - \\overline{a})^2 + \\cdots + (a_n - \\overline{a})^2}{n}$,其中 $\\overline{a}$ 表示 $a$ 序列的平均数,即为...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments