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. 【bzoj4653】[Noi2016]区间

    离散化+线段树 #include<algorithm> #include<iostream> #include<cstdlib> #include<cstri ...

  2. 从源码理解 ThreadLocal

    为每个线程保存各自的拷贝,可以通过在Thread类中定义一个成员变量来保存每个线程值,这样也是线程安全的. 通过定义一个成员变量 sn 来实现,这里并没有使用ThreadLocal类来实现: publ ...

  3. 正则表达式、Calendar类、SimpleDateFormat类、Date类、BigDecimal类、BigInteger类、System类、Random类、Math类(Java基础知识十四)

    1.正则表达式的概述和简单使用 * A:正则表达式(一个字符串,是规则)     * 是指一个用来描述或者匹配一系列符合某个语法规则的字符串的单个字符串.其实就是一种规则.有自己特殊的应用. * B: ...

  4. html5--6-41 CSS背景

    html5--6-41 CSS背景 实例 学习要点 掌握CSS背景属性的使用 元素的背景属性: background 简写属性,作用是将背景属性设置在一个声明中. background-attachm ...

  5. [置顶] SQL Server 2005 双机热备的实现

    [置顶] SQL Server 2005 双机热备的实现 分类: SQLSERVER2011-08-24 21:25 901人阅读 评论(0) 收藏 举报 sql servermicrosoftsql ...

  6. codeforces round 420 div2 补题 CF 821 A-E

    A Okabe and Future Gadget Laboratory 暴力 #include<bits/stdc++.h> using namespace std; typedef l ...

  7. B - Preparing Olympiad

    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description You ha ...

  8. View Programming Guide for iOS ---- iOS 视图编程指南(四)---Views

    Views Because view objects are the main way your application interacts with the user, they have many ...

  9. 让ubuntu16.04开机进入命令行模式

    使用Ubuntu时,有时候我们不想开机进入桌面,想直接进入命令行,这样启动的比较快, 1.首先我们修改grub文件,改为如图所示: sudo gedit  /etc/default/grub 改完之后 ...

  10. android:ellipsize省略文字用法(转载)

    转自:http://zhangkun716717-126-com.iteye.com/blog/864989 TextView及其子类,当字符内容太长显示不下时可以省略号代替未显示的字符:省略号可以在 ...