-
Notifications
You must be signed in to change notification settings - Fork 13
/
dolbears-law.cpp
53 lines (46 loc) · 1.09 KB
/
dolbears-law.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
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
int main()
{
string line;
int M; cin >> M; cin.ignore();
vector<int> temps;
float N60_mean = 0.f, N8_mean = 0.f;
for (int i = 0; i < M; i++)
{
getline(cin, line);
istringstream iss(line);
for(string s; iss >> s; )
{
temps.push_back(stoi(s));
}
}
int i = 0;
do {
auto it = temps.begin() + i;
N60_mean += 10 + (accumulate( it, it + 15, 0) - 40)/7.f;
i += 15;
} while( i + 15 <= temps.size() );
i = 0;
int j = 0;
do {
j++;
auto it = temps.begin() + i;
N8_mean += 5 + accumulate( it, it + 2, 0);
i += 2;
} while( i + 2 <= temps.size() );
N60_mean/=M;
N8_mean /=j;
cout << fixed << setprecision(1) << (float)N60_mean << endl;
if( N60_mean >= 5 && N60_mean <= 30 )
{
cout << fixed << setprecision(1) << N8_mean << endl;
}
}