Diplomas and Certificates (Codeforces
来源:互联网 发布:中昌数据什么时候开盘 编辑:程序博客网 时间:2024/06/08 18:32
题目链接 http://codeforces.com/problemset/problem/818/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 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 ≤ 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
题目大意:
解题思路:
代码:
#include<iostream>using namespace std;int main(){ long long int n,k,half,ans1,ans2,ans3; while(cin>>n>>k) { half=n/2; ans1=half/(k+1); ans2=k*ans1; ans3=n-ans1-ans2; cout<<ans1<<' '<<ans2<<' '<<ans3<<endl; } return 0;}
- Diplomas and Certificates (Codeforces
- Codeforces 818A Diplomas and Certificates
- CF818A-Diplomas and Certificates
- Diplomas and Certificates
- Educational Codeforces Round 24A Diplomas and Certificates
- codeforces A. Ilya and Diplomas
- CodeForces#311 A. Ilya and Diplomas
- Codeforces 557A Ilya and Diplomas 【水题】
- CodeForces 557A-Ilya and Diplomas【模拟】
- CodeForces 557A Ilya and Diplomas
- CodeForces - 557A Ilya and Diplomas
- CodeForces 557A Ilya and Diplomas
- 【55.70%】【codeforces 557A】Ilya and Diplomas
- Codeforces Round #311 (Div. 2)A Ilya and Diplomas
- Codeforces 557A Ilya and Diplomas 区间选数
- Codeforces Round #311 (Div. 2) A. Ilya and Diplomas
- A. Ilya and Diplomas( Codeforces Round #311 (Div. 2) )
- CodeForces - 557A Ilya and Diplomas (模拟)水
- 砝码称重
- C++中,有哪4种与类型转换相关的关键字?各有什么特点?应该在什么场合下使用?
- 实践mahout推荐引擎
- setTimeout,异步,原理
- EasyTalk 项目介绍
- Diplomas and Certificates (Codeforces
- SVM+HOG对图像进行多分类(OpenCV实现)
- MapReduce练习:DataJoin联结练习
- [iOS [转] CAEmitterLayers属性解释] 鱼缸气泡效果(非完美)
- 爬取动态的网页。
- 一次完整的HTTP请求过程
- 教你如何迅速秒杀掉:99%的海量数据处理面试题
- 为什么选择Nginx
- iOS 长按复制文本