-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtemplate.cpp
57 lines (47 loc) · 1.04 KB
/
template.cpp
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
#pragma comment(linker, "/STACK:268435456")
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <numeric>
using namespace std;
int main() {
string name = "A-small";
string path = "";
freopen((path + name + ".in").c_str(), "r", stdin);
freopen((path + name + ".out").c_str(), "w", stdout);
int test_cases;
cin >> test_cases;
for (int test_case = 1; test_case <= test_cases; test_case++) {
string cmd;
cin >> cmd;
int n;
cin >> n;
vector<double> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
double res;
if (cmd == "median") {
sort(a.begin(), a.end());
res = a[n / 2];
} else if (cmd == "mean") {
res = accumulate(a.begin(), a.end(), 0.0) / n;
}
cout << "Case #" << test_case << ": " << fixed << setprecision(10) << res << endl;
cout.flush();
}
fclose(stdout);
fclose(stdin);
return 0;
}