[C++] baekjoon 10984, 10833

oat·2024년 3월 3일

everydayBOJ

목록 보기
30/51

Day 30

10984

문제

code

#include<iostream>

using namespace std;

int main() {
    int T;
    cin >> T;

    int C;
    double G;

    for (int i = 0; i < T; i++) {
        int N;
        cin >> N;
        double total = 0;
        int ctotal = 0;
        for (int j = 0; j < N; j++) {
            cin >> C >> G;
            total += C * G;
            ctotal += C;
        }
        cout << ctotal << " ";
        cout << fixed;
        cout.precision(1);
        cout << total / ctotal << endl;
        
    }
}

풀이 과정

학점 * 성적 / 총 학점 을 계산하여 출력하도록 하였다
cout << fixed;
cout.precision(1);
소수 첫째 자리로 고정하였다


10833

문제

code

#include<iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int total = 0;

    for (int i = 0; i < N; i++) {
        int students;
        int apples;
        cin >> students >> apples;
        total += apples % students;
    }
    cout << total;
}

풀이 과정

사과 개수를 각 학교 학생 수로 나누어서 총 남은 사과 수에 더하도록 하였다

0개의 댓글