Random Teams
Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could have formed by the end of the competition.
The only line of input contains two integers n and m, separated by a single space (1 ≤ m ≤ n ≤ 109) — the number of participants and the number of teams respectively.
The only line of the output should contain two integers kmin and kmax — the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.
5 1
10 10
3 2
1 1
6 3
3 6
In the first sample all the participants get into one team, so there will be exactly ten pairs of friends.
In the second sample at any possible arrangement one team will always have two participants and the other team will always have one participant. Thus, the number of pairs of friends will always be equal to one.
In the third sample minimum number of newly formed friendships can be achieved if participants were split on teams consisting of 2people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people.
其实题目可以转化为
A1+A2+...+An=n;
求C(A1,2)+C(A2,2)+C(A3,2)+...+C(An,2)的最大最小值
利用高中学过的基本不等式就可以了
其实 好像用常识就可以解题了,,,我认为。。。
#include<iostream>
using namespace std;
long long int fun(long long int i){
if(i<)return ;
if(i%==)return (i-)/*i;
return i/*(i-);
}
int main(){
long long int n,m;
while(cin>>n>>m){
long long int t=n/m;
long long int t1=n%m;
long long int mi;
mi=fun(t+)*t1+fun(t)*(m-t1);
long long int ma=fun(n-m+);
cout<<mi<<" "<<ma<<endl;
}
return ;
}
Random Teams的更多相关文章
- cf478B Random Teams
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- codeforces 478B Random Teams
codeforces 478B Random Teams 解题报告 题目链接:cm.hust.edu.cn/vjudge/contest/view.action?cid=88890#probl ...
- B. Random Teams(Codeforces Round 273)
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 【CODEFORCES】 B. Random Teams
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #273 (Div. 2)-B. Random Teams
http://codeforces.com/contest/478/problem/B B. Random Teams time limit per test 1 second memory limi ...
- Codeforces Round #273 (Div. 2) B . Random Teams 贪心
B. Random Teams n participants of the competition were split into m teams in some manner so that e ...
- CF478 B. Random Teams 组合数学 简单题
n participants of the competition were split into m teams in some manner so that each team has at le ...
- codeforces 478B Random Teams 解题报告
题目链接:http://codeforces.com/problemset/problem/478/B 题目意思:有 n 个人,需要将这班人分成 m 个 组,每个组至少含有一个人,同一个组里的人两两可 ...
- cf478B-Random Teams 【排列组合】
http://codeforces.com/problemset/problem/478/B B. Random Teams n participants of the competition w ...
随机推荐
- 2013 南京邀请赛 C count the carries
/** 大意: 给定区间(a,b), 将其转化为二进制 计算从a+(a+1)+(a+2)....+(a+b-1),一共有多少次进位 思路: 将(a,b)区间内的数,转化为二进制后,看其每一位一共有多少 ...
- 高级UNIX环境编程11 线程
<pthread.h> pthread_equal pthread_self(void) pthread_create() pthread_close() pthread_join() p ...
- Linux下gsoap实现webservice功能
蓝字为关键字,等号=后面为关键字值. 一.介绍 我们用的webservice是根据gsoap编译工具来实现,gSOAP的编译器能够自动的将用户定义的本地化的C或C++数据类型转变为符合XML语法的数据 ...
- 启动(Startup)
Startup Chrome是一个单一的可执行程序.它清楚如何运行其它进程. 下面是chrome启动的概述: 1. 首先,chrome有一个平台相关的入口点:在windows上是wWinMain(): ...
- 邀请朋友富途开户赢iPhone6的史上最强攻略
最近有关沪港通的消息很多,加上阿里巴巴马上IPO,所以上个月我在朋友推荐下,来富途开了个户.本来对邀请不太感兴趣,但这次的奖品实在诱人,因为超级想要iPhone6,所以也加入了邀请大队.到发贴的时候, ...
- ArcGIS Engine 改变线IPolyline的方向
有时候需要改变一下线的方向来组成要要的图形,可以按一下方法来变换一下. 如果看官有好的方法的话,请不吝贴上为谢! private IPolyline ChangeDirection(IPolyline ...
- 【linux】 linux gpio操作
欢迎转载,转载时需保留作者信息,谢谢. 邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http:// ...
- listview,fragment结合起来
这是csdn上的以个demo,很适合初学者.来源:http://download.csdn.net/detail/endlife99/7274419,侵删. MainActiviy: package ...
- 在Windows下github展示代码
最近大爱Web编程,于是寻找各种代码中,然后就发现了GitHub这个网站,如果你知道Google Code,那么你就知道这个GitHub是做什么的了.不过GitHub主要是用作基于Git的分布式版本管 ...
- sqlite可视化工具以及django-South
在linux系统下想要可视化sqlite的办法 一:安装sqlitebrowser: sudo apt-get install sqlitebrowser 二:在终端提示符后输入sqlitebrows ...