부동 소수점, 고정 소수점에 대한 개념과 사용법을 알고 있다면 풀기 쉬운 문제였다.
#include <iostream>
#include <vector>
int main(void) {
// Declare variable
unsigned int numberOfSubject;
unsigned int maxOfScore = 0;
unsigned int sumOfScore = 0;
long double result;
std::vector<unsigned int> scoreVector;
// Input
std::cin >> numberOfSubject;
// Vector setting
for(int i = 0; i < numberOfSubject; i++) {
unsigned int score;
std::cin >> score;
sumOfScore += score;
scoreVector.push_back(score);
if(maxOfScore < score) {
maxOfScore = score;
}
}
// Set Precision
std::cout.precision(15);
// Change to Fixed-Point Representation
std::cout << std::fixed;
// Caculate result
result = (long double) (sumOfScore * 100) / (maxOfScore * numberOfSubject);
// Output
std::cout << result << std::endl;
}