Nathan Coulas

DMOPC '14 Contest 1 P3 - New Students

dmopc14c1p3 CPP17 02 May, 2020 0.095s 7 points

Source Code

#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n, s;
	cin >> n;
	int t;
	double avg = 0;
	int c = 0;
	
	for(int i = 0; i < n; i++){
		cin >> t;
		avg += t;
	}
	
	cin >> s;
	c = n;
	for(int i = 0; i < s; i++){
		cin >> t;
		c++;
		avg += t; 
		cout << setprecision(5) << (avg / c);
		if( fmod(avg / c, 1) == 0){
			cout << ".000";
		}
		cout << "\n";
		
	}

	
	return 0;
}