Recent Posts
Notice
No Rules Rules
대표값2 (feat. 백준, 2587번) 본문
728x90
반응형
대표값2
https://www.acmicpc.net/problem/2587
2587번: 대표값2
어떤 수들이 있을 때, 그 수들을 대표하는 값으로 가장 흔하게 쓰이는 것은 평균이다. 평균은 주어진 모든 수의 합을 수의 개수로 나눈 것이다. 예를 들어 10, 40, 30, 60, 30의 평균은 (10 + 40 + 30 + 60 +
www.acmicpc.net
// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
ios::sync_with_stdio(false), cin.tie(NULL);
vector<int> ans;
for(register int i = 0, v; i < 5; ++i)
cin >> v, ans.push_back(v);
sort(ans.begin(), ans.end());
cout << accumulate(ans.begin(), ans.end(), 0) / ans.size() << "\n" << ans[ans.size() / 2];
return 0;
}
// *&)*@*
반응형
단순 연산 문제입니다.
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
체스 (feat. 백준, 17122번) (0) | 2022.10.26 |
---|---|
색종이 (feat. 백준, 2563번) (0) | 2022.10.26 |
막대기 (feat. 백준, 1094번) (0) | 2022.10.25 |
케빈 베이컨의 6단계 법칙 (feat. 백준, 1389번) (0) | 2022.10.24 |
최댓값 (feat. 백준, 2566번) (0) | 2022.10.24 |
Comments