1 条题解
-
0
参考答案:
#include<iostream> #include<algorithm> #include<math.h> const int N = 10010; using namespace std; int a[N]; int main() { int t; cin >> t; while (t--) { double fc = 0, sum = 0, avg = 0; int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; } avg = sum / (double)n; sort(a, a + n); cout << a[n - 1] - a[0] << ' '; for (int i = 0; i < n; ++i) { fc += pow(a[i] - avg, 2); } printf("%.6lf\n", fc / (double)n); } return 0; }
- 1
信息
- ID
- 5398
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- (无)
- 递交数
- 10
- 已通过
- 5
- 上传者