CF818A.Diplomas and Certificates
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
共有 n 名学生参加了奥林匹克竞赛。现在到了为这些学生颁奖的时候了。
其中一部分学生将获得文凭(diplomas),一部分将获得证书(certificates),其余学生则什么也得不到。获得文凭或证书的学生统称为获奖者(winners)。但文凭与证书的数量需满足以下规则:
- 证书数量必须恰好是文凭数量的 k 倍;
- 获奖者总数不得超过全体学生人数的一半(即不得超过 2n);
- 允许不存在任何获奖者(即获奖者人数可为 0)。
你需要根据上述规则,求出获奖者人数的最大可能值;并在此前提下,分别计算:
- 获得文凭的学生人数,
- 获得证书的学生人数,
- 未获奖的学生人数。
输入格式
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.
输入的第一行(也是唯一一行)包含两个整数 n 和 k(1 ≤ n,k ≤ 1012),其中 n 表示学生人数,k 表示证书数量与文凭数量的比值。
输出格式
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.
输出三个数字:获得文凭的学生人数、获得证书的学生人数,以及未获奖的学生人数(在获奖学生人数达到最大可能值的情况下)。
可能存在没有获奖者的情况。
输入输出样例
输入#1
18 2
输出#1
3 6 9
输入#2
9 10
输出#2
0 0 9
输入#3
1000000000000 5
输出#3
83333333333 416666666665 500000000002
输入#4
1000000000000 499999999999
输出#4
1 499999999999 500000000000
输入解题思路,AI测评打分。不知道怎么写?