작성일 :

문제 링크

15921번 - 수찬은 마린보이야!!

설명

평균을 기댓값으로 나눈 값을 구하는 문제입니다.


접근법

동일한 데이터에서 평균과 기댓값은 항상 같습니다.

따라서 데이터가 존재하면 결과는 항상 1.00입니다.

n이 0이면 데이터가 없으므로 divide by zero를 출력합니다.



Code

C#

1
2
3
4
5
6
7
8
9
10
11
12
13
using System;

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine()!);
    if (n == 0) {
      Console.WriteLine("divide by zero");
      return;
    }
    Console.ReadLine();
    Console.WriteLine("1.00");
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  if (!(cin >> n)) return 0;
  if (n == 0) {
    cout << "divide by zero\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
  }
  cout << "1.00\n";

  return 0;
}