cf478B Random Teams
n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.
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 2 people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people.
n个人分到m组里,每一组对于答案的贡献是人数排列组合,就是n*(n-1)/2。求最大值和最小值
显然前面取m-1组的1最后一组最大的方案是答案最大
平均分的方案是答案最小
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
LL a,b,c,d,e;
int main()
{
a=read();b=read();
c=(a-b+)*(a-b)/;
d=(a-b*(a/b));
e=(d)*(a/b+)*(a/b)/+(b-d)*(a/b)*(a/b-)/;
printf("%lld %lld\n",e,c);
}
cf478B
cf478B Random Teams的更多相关文章
- 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 ...
- 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 ...
随机推荐
- cf448D Multiplication Table
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...
- VM虚拟机安装苹果雪豹操作系统
1.win xp虚拟机安装Mac OSX 一.用VM8安装mac os x10.6 ,然后升级到的10.6.8,如何安装vm大家自己百度吧.这里指列出了如何安装雪豹操作系统. DMG是mac os x ...
- hdu 1829 A Bug's Life(并查集)
A Bu ...
- 你被adblock坑过吗?
最近上线一个新版本,需要在导航增加一个app的下载入口(一个图片链接),然后经过了正常的原型图.设计.切图.上线的过程,一切都是那么顺利.上线之后,像往常一下会让产品进行确认,所有的调整和优化 ...
- PHP里关于时间日期大小写(Y,y,M,m...)
y代表年份,取后两位 Y代表年份全部 m代表月份 M代表月份英文简写 d代表天 D代表星期几的简写 h代表小时,12 ...
- Linux环境 Mysql新建用户和数据库并授权
测试环境:linux 和Mysql 5.5.35 一.新建用户 //登录Mysql@>mysql -u root -p@>密码//创建用户mysql> insert into mys ...
- 介绍一款Android小游戏--交互式人机对战五子棋
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6589025 学习Android系统开发之余,编 ...
- IoC容器Autofac正篇之类型关联(服务暴露)(七)
类型关联 类型关联就是将类挂载到接口(一个或多个)上去,以方便外部以统一的方式进行调用(看下例). 一.As关联 我们在进行手动关联时,基本都是使用As进行关联的. class Program { s ...
- Sublime 学习记录(二) package control 组件
i. 按Ctrl + ` 调出console (如果有QQ输入法会有冲突需要关闭热键) ii. 粘贴以下代码到底部命令行并运行 import urllib.requ ...
- C# WinFrom 导入Excel文件,显示进度条
因为WINForm程序是在64位上运行如果使用另外一种快速的读取Excel的方法会报“未在本地计算机上注册“Microsoft.Jet.OLEDB.12.0”提供程序” 所以我就换了现在这种读取有点慢 ...