Educational Codeforces Round 24 A
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.
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 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.
18 2
3 6 9
9 10
0 0 9
1000000000000 5
83333333333 416666666665 500000000002
1000000000000 499999999999
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的更多相关文章
- 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 ...
- Educational Codeforces Round 24 CF 818 A-G 补题
6月快要结束了 期末也过去大半了 马上就是大三狗了 取消了小学期后20周的学期真心长, 看着各种北方的学校都放假嗨皮了,我们这个在北回归线的学校,还在忍受酷暑. 过年的时候下定决心要拿块ACM的牌子, ...
- Educational Codeforces Round 24 E
Vova again tries to play some computer card game. The rules of deck creation in this game are simple ...
- codeforces Educational Codeforces Round 24 (A~F)
题目链接:http://codeforces.com/contest/818 A. Diplomas and Certificates 题解:水题 #include <iostream> ...
- Educational Codeforces Round 24
A. Diplomas and Certificates time limit per test 1 second memory limit per test 256 megabytes input ...
- 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 ...
- Educational Codeforces Round 24 B
n children are standing in a circle and playing a game. Children's numbers in clockwise order form a ...
- Educational Codeforces Round 24 题解
A: 考你会不会除法 //By SiriusRen #include <bits/stdc++.h> using namespace std; #define int long long ...
- Educational Codeforces Round 32
http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...
随机推荐
- linux 输入子系统(4) intput_dev 接口描述
Name struct input_dev - represents an input device Synopsis struct input_dev { const char * name; // ...
- mac系统不同java版本切换
#确认jdk版本 /usr/libexec/java_home #会得到下面信息(不同版本显示不一样) /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jd ...
- Python开发【2.2 异常处理】
1.Python常见异常类型: Exception 常规错误的基类 AttributeError 对象没有这个属性 IOError 输入/输出操作失败 IndexError 序列中没有此索引(inde ...
- scala快速学习笔记(一):变量函数,操作符,基本类型
为了用spark,先学下scala. 参考教程:http://meetfp.com/zh/scala-basic doc查询:http://docs.scala-lang.org 其它资料:http: ...
- Android app身体质量指数(BMI)
针对中国人的标准身高体重来測算,提示您身体的健康状况. 提示您是否应该锻炼.节食或者补充营养等.第一时间知道您的健康状况. 下载地址:http://android.myapp.com/myapp/de ...
- Deep Learning 31: 不同版本的keras,对同样的代码,得到不同结果的原因总结
一.疑问 这几天一直纠结于一个问题: 同样的代码,为什么在keras的0.3.3版本中,拟合得比较好,也没有过拟合,验证集准确率一直高于训练准确率. 但是在换到keras的1.2.0版本中的时候,就过 ...
- mysql优化-----索引覆盖
一道面试题: 有商品表, 有主键,goods_id, 栏目列 cat_id, 价格price 说:在价格列上已经加了索引,但按价格查询还是很慢,问可能是什么原因,怎么解决? 答:在实际场景中,一个电商 ...
- gitbash使用
gitbash是什么 git bash是Windows下的命令行工具. 基于msys GNU环境,有git分布式版本控制工具. 主要用于git版本控制,上传下载项目代码. GNU环境,就是说如果你喜欢 ...
- android提权漏洞CVE-2010-EASY修复【转】
本文转载自: http://blog.csdn.net/lhj0711010212/article/details/9351131 android提权漏洞CVE-2010-EASY修复 linux ...
- WAS:修改jsp编译器用JDK5.0
问题现象: 今天有现场反映,访问应用的个别页面报错,报错内容如下: 于是先查看其他现场,都是好的:根据报错信息,提示的意思是jsp解析不了. 结合上面2个情况,排除代码问题,应该是现场WAS环境问 ...