Discription
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and certificates. The number of certificates must be exactly k times greater than the number of diplomas. The number of winners must not be greater than half of the number of all students (i.e. not be greater than half of n). It's possible that there are no winners.
You have to identify the maximum possible number of winners, according to these rules. Also for this case you have to calculate the number of students with diplomas, the number of students with certificates and the number of students who are not winners.
Input
The first (and the only) line of input contains two integers n and k (1 ≤ n, k ≤ 1012), where n is the number of students and k is the ratio between the number of certificates and the number of diplomas.
Output
Output three numbers: the number of students with diplomas, the number of students with certificates and the number of students who are not winners in case when the number of winners is maximum possible.
It's possible that there are no winners.
题意:N只队伍,要产生不超过N/2块奖牌,其中A类奖牌恰好是B类的两倍
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
long long winner = n / 2;
long long ce = winner / (m + 1);
long long di = ce * m;
long long other = n - ce - di;
cout << ce << " " << di << " " << other << endl;
return 0;
}
本文探讨了在学生竞赛中,如何根据特定规则确定获奖者数量的最大化策略。通过算法解析,我们了解了如何计算不同奖项的分配,确保获奖者总数不超过参赛学生的一半,同时满足证书与文凭数量的特定比例。
4346

被折叠的 条评论
为什么被折叠?



