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++,包括极大和极小 ...
随机推荐
- ubuntu搭建samba服务器
一.为什么要用Samba? Samba的主要任务就是实现Linux系统和Windows系统之间的资源共享. 二.需要的软件? 我是在ubuntu上实现的,所以我只需在配置好ubuntu的更 ...
- 使用mysql导入数据时关掉binlog
在my.cnf中注释掉 log-bin=bin-log参数然后重启数据库
- RecyclerView(替代ListView)使用方法介绍
在build.gradle文件加入以下代码 compile 'com.android.support:cardview-v7:21.0.3' compile 'com.android.support: ...
- 网页Html代码优化及分析
- iOS UI控件之间的关系图
- ubuntu16.04和服务器 caffe 安装
在centos6.X上安装caffe 0.编译安装gcc4.8.5 由于centos6.x中的gcc版本老旧,不支持c++11所以要安装gcc4.8.5,以下是安装教程.参考CentOS 6.4 编译 ...
- 汉字与区位码互转(天天使用Delphi的String存储的是内码,Windows记事本存储的文件也是内码),几个常见汉字的各种编码,utf8与unicode的编码在线查询,附有读书笔记 good
汉=BABA(内码)=-A0A0=2626(区位码)字=D7D6(内码)=-A0A0=5554(区位码) 各种编码查询表:http://bm.kdd.cc/ 汉(记住它,以后碰到内存里的数值,就会有敏 ...
- CodeChef:Little Elephant and Colored Coins
类似墨墨的等式 设f[2][j][k]表示a[i].c是否和当前颜色相同,到当前枚举到的颜色为止,颜色数为j,对mnv取模为k的最小数 这是个无限循环背包,用spfa优化 #include<cs ...
- LoadRunner使用动态链接库技术
什么是动态库? 动态库一般又叫动态链接库英文为DLL,是Dynamic Link Library 的缩写形式,DLL是一个包含可由多个程序同时使用的代码和数据的库,DLL不是可执行文件.动态链接提供了 ...
- html5--6-56 阶段练习5-翻转效果
html5--6-56 阶段练习5-翻转效果 学习要点 运用所学过的知识完成一个简单的小练习,理解对动画的应用. @charset="UTF-8"; *{ ; ; } img{ w ...