1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

競プロ日記#25/05/01

Posted at

アルゴ式-かたよったくじ (1)

  • 絶対誤差の出力をそのうちしっかり理解せねばと思っている
int main() {
    int N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    // 絶対誤差10-6以下の精度で出力する
    cout << fixed << setprecision(15) << (double)sum / N << endl;
}

アルゴ式-かたよったくじ (2)

int main() {
    int M;
    cin >> M;
    int sum = 0;
    int countSum = 0;
    for (int i = 0; i < M; i++) {
        int A,c;
        cin >> A >> c;
        sum += A * c;
        countSum += c;
    }

    cout << fixed << setprecision(15) << (double)sum / countSum << endl;
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?