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 beexactly 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个人参赛,必须保证获奖A的人数是获奖B的k倍,获奖人数不得超过总数的1/2,并输出未获奖人数
解法:
1 都没获奖的情况 即获奖A为1人,获奖B为k人,一共为1+k,但大于num/2
2 接下来的获奖情况 获奖A为x人,那么获奖B为xk人,一共x(1+k)==num
 #include<bits/stdc++.h>
using namespace std;
int main()
{
long long n;
long long k;
cin>>n>>k;
long long num=n/;
long long sum=;
if(+k>num)
{
cout<<"0 0 "<<n<<endl;
}
else
{
long long x=num/(+k); cout<<x<<" "<<x*k<<" "<<n-(x+x*k)<<endl;
}
return ;
}

Educational Codeforces Round 24 A的更多相关文章

  1. Educational Codeforces Round 24 A 水 B stl C 暴力 D stl模拟 E 二分

    A. Diplomas and Certificates time limit per test 1 second memory limit per test 256 megabytes input ...

  2. Educational Codeforces Round 24 CF 818 A-G 补题

    6月快要结束了 期末也过去大半了 马上就是大三狗了 取消了小学期后20周的学期真心长, 看着各种北方的学校都放假嗨皮了,我们这个在北回归线的学校,还在忍受酷暑. 过年的时候下定决心要拿块ACM的牌子, ...

  3. Educational Codeforces Round 24 E

    Vova again tries to play some computer card game. The rules of deck creation in this game are simple ...

  4. codeforces Educational Codeforces Round 24 (A~F)

    题目链接:http://codeforces.com/contest/818 A. Diplomas and Certificates 题解:水题 #include <iostream> ...

  5. Educational Codeforces Round 24

    A. Diplomas and Certificates time limit per test 1 second memory limit per test 256 megabytes input ...

  6. Educational Codeforces Round 24 D

    Alice and Bob got very bored during a long car trip so they decided to play a game. From the window ...

  7. Educational Codeforces Round 24 B

    n children are standing in a circle and playing a game. Children's numbers in clockwise order form a ...

  8. Educational Codeforces Round 24 题解

    A: 考你会不会除法 //By SiriusRen #include <bits/stdc++.h> using namespace std; #define int long long ...

  9. Educational Codeforces Round 32

    http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...

随机推荐

  1. HDOJ_ How can I read input data until the end of file ?

    Language C C++ Pascal To read numbers int n;while(scanf("%d", &n) != EOF){ ...} int n; ...

  2. Drupal 7模板(主题钩子)的建议

    这一块的内容很多其它的讲的是样例.所以这里请直接稳步官方站点查看吧.链接 https://drupal.org/node/1089656

  3. js-easyUI格式化时间

    formatter : function(value, row) { if(value != null){ var date = new Date(value); var y = date.getFu ...

  4. Ext js框架模拟Windows桌面菜单管理模板

    一款超炫的后台,Ext模拟Windows桌面,Ext经典浅蓝风格,功能非常强大,包括最大化.最小化.状态栏.桌面图标等,不过需要非常懂Ext脚本的才可驾驭它.​ 1.图片 ​2. [代码][HTML] ...

  5. iOS--控制器加载自定义view的xib

    我们在项目中,经常需要使用到自定义的view,而xib布局显得更为简洁,那么如何加载一个自定义的xib呢,网上的方法也很多很多,就是因为太多了,我经常会弄混,所以总结其中一个使用,如果以后使用到其他的 ...

  6. 一步一步学Silverlight 2系列(12):数据与通信之WebClient

    概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...

  7. sid, pid, gid

    (一) 参考 :https://unix.stackexchange.com/questions/18166/what-are-session-leaders-in-ps 命令: ps xao pid ...

  8. DFS Used%: NaN%问题

    一.问题描述: [root@master sbin]# hdfs dfsadmin -report Configured Capacity: 0 (0 B) Present Capacity: 0 ( ...

  9. 「网络流24题」「LuoguP4014」 分配问题

    Description 有 n 件工作要分配给 n 个人做.第 i 个人做第 j 件工作产生的效益为 cij.试设计一个将 n 件工作分配给 n 个人做的分配方案,使产生的总效益最大. Input 文 ...

  10. bzoj3143游走——期望+高斯消元

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3143 只需算出每条边被经过的概率,将概率从小到大排序,从大到小编号,就可得到最小期望: 每条 ...