※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 25858번 문제인 Divide the Cash이다.
문제는 아래 링크를 확인하자.
https://www.acmicpc.net/problem/25858
25858번: Divide the Cash
The UCF Programming Team coaches schedule practices regularly in fall and spring (by the way, all UCF students are welcome to the practices). During summer, the majority of the team members are gone but the coaches know how to make sure the students don’
www.acmicpc.net
학생들에게 분배될 액수 총액 d가 주어진 학생들이 해결한 문제 개수의 총합 S의 배수임이 보장되므로, 각 학생별로 d를 S로 나눈 값과 그 학생들이 해결한 문제의 수를 곱한 값을 출력하는 것으로 문제를 해결할 수 있다.
아래는 제출한 소스코드이다.
#include <iostream>
using namespace std;
int n, d;
int arr[30];
int total;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> d;
for (int i = 0; i < n; i++) {
cin >> arr[i];
total += arr[i];
}
d /= total;
for (int i = 0; i < n; i++) cout << arr[i] * d << '\n';
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 25801 // C++] Odd/Even Strings (0) | 2022.10.30 |
---|---|
[BOJ 25881 // C++] Electric Bill (0) | 2022.10.30 |
[BOJ 25894 // C++] Phoneme Palindromes (1) | 2022.10.30 |
[BOJ 11121 // C++] Communication Channel (0) | 2022.10.30 |
[BOJ 21665 // C++] Миша и негатив (1) | 2022.10.30 |