Codeforces 818A Diplomas and Certificates

5 篇文章 0 订阅
4 篇文章 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.

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.

Examples
input
18 2
output
3 6 9
input
9 10
output
0 0 9
input
1000000000000 5
output
83333333333 416666666665 500000000002
input
1000000000000 499999999999
output
1 499999999999 500000000000
 
        
题目大意:有学位证和毕业证才叫做牛逼的人,如果只有一个或者一个都没有则不是牛逼的人,现在给你一个n,代表总人数,一个k,代表两个证之间的比率,让你求再牛逼的人最多的情况下,只有学位证的人数,只有毕业证的人数,不牛逼的人数。(牛逼的人数最多为n/2)
 
        
AC代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main()
{
    int n, k;
    scanf("%I64d%I64d", &n, &k);
    printf("%I64d %I64d %I64d\n", n/(2*(k+1)), n/(2*(k+1)) * k, n - n/(2*(k+1)) - n/(2*(k+1))* k);
}

 
       


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值