A11015 | Diplomas and Certificates
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first (and the only) line of input contains two integers $n$ and $k$ ( $1<=n,k<=10^{12}$ ), where $n$ is the number of students and $k$ is the ratio between the number of certificates and the number of diplomas.
输出格式
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted