include iostream include vector include algorithm using namespace std

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector <double> a1;
vector <double> a2;
double x (int n, vector <double> a)
{
double answer = 0.0;
for (int i = 0; i < n; ++i)
{
answer += a[i];
}
return answer / n;
}
double s (int n, double x, vector <double> a)
{
double answer = 0.0;
for (int i = 0; i < n; ++i)
{
answer += (a[i] - x) * (a[i] - x);
}
return answer / (n - 1);
}
double x_y (int n1, int n2, double x1, double x2)
{
return (x1 * n1 + x2 * n2) / (n1 + n2);
}
double s_y (int n1, int n2, double s1, double s2)
{
return sqrt ((s1 * (n1 - 1) + s2 * (n2 - 1)) / (n1 + n2 - 2));
}
double gist ()
{
for (int i = 0; i < a2.size(); ++i)
{
a1.push_back (a2[i]);
}
sort (a1.begin(), a1.end());
cout << "min " << a1[0] << endl << "max " << a1[a1.size() - 1] << endl;
return (a1[a1.size() - 1] - a1[0]) / 10;
}
int main()
{
/*freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);*/
int n1, n2;
double tmp, x1, x2, s1, s2, xy, sy;
cin >> n1;
for (int i = 0; i < n1; ++i)
{
cin >> tmp;
a1.push_back(tmp);
}
cin >> n2;
for (int i = 0; i < n2; ++i)
{
cin >> tmp;
a2.push_back(tmp);
}
x1 = x (n1, a1);
x2 = x (n2, a2);
s1 = s (n1, x1, a1);
s2 = s (n2, x2, a2);
xy = x_y (n1, n2, x1, x2);
sy = s_y (n1, n2, s1, s2);
cout << x1 << endl;
cout << x2 << endl;
cout << sqrt (s1) << endl;
cout << sqrt (s2) << endl;
cout << xy << endl;
cout << sy << endl;
cout << gist () << endl;
system ("pause");
return 0;
}