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 ...
随机推荐
- C/C++四种退出线程的方法
退出线程可以有四种方法: 1.线程函数的return返回(最好这样): 其中用线程函数的return返回, 而终止线程是最安全的, 在线程函数return返回后, 会清理函数内申请的类对象, 即调用这 ...
- 将DataTable转化为json对象
private string DataTableTojson(DataTable dt) { List> list=new List>(); ...
- WEB打印插件jatoolsPrinter
为什么选择 jatoolsPrinter 免费版? 支持无预览直接打印 真正免费,不加水印,没有ip或域名限制,不限时间,兼容ie6+ 无须注册,下载即用 提供经过微软数字签名的cab自动安装包,安装 ...
- 精确覆盖DLX算法模板
代码 struct DLX { int n,id; int L[maxn],R[maxn],U[maxn],D[maxn]; ]; ) //传列长 { n=nn; ;i<=n;i++) U[i] ...
- 神坑 关于&&的取值
a = 0&&"ssss": 结果a=0 a=true&&"w": 结果a=w: 类似于 前面是真的 会执行后面并返回后面 前面 ...
- 使用Open Flash Chart(OFC)制作图表(Struts2处理)
Java开源项目中制作图表比较出色的就是JFreeChart了,相信大家都听说过,它不仅可以做出非常漂亮的柱状图,饼状图,折线图基本图形之外,还能制作甘特图,仪表盘等图表.在Web应用中可以为项目增色 ...
- Java之Static静态修饰符详解
Java之Static静态修饰符详解 Java之Static静态修饰符详解 一.特点 1.随着类的加载而加载,随着类的消失而消失,生命周期最长 2.优先于对象存在 3.被所有类的对象共享 4.可以直接 ...
- OMXCodec与OMX事件处理流程
学习了解Mutilmedia Framework有一段时间了,今天闲下来稍微整理整理.OMXCodec.cpp类属于libstagefright,在整个MM PF 相当OMX的适配层,供awesome ...
- 《JavaScript 闯关记》之 BOM
ECMAScript 是 JavaScript 的核心,但如果要在 Web 中使用 JavaScript,那么 BOM(浏览器对象模型)则无疑才是真正的核心.BOM 提供了很多对象,用于访问浏览器的功 ...
- ie11加载不了css的问题
ie11打开页面,竟然一点css都没有加载出来,而且是老大的电脑遇到了这个问题,啃爹啊 上网查资料,做了如下修改: 1.pc端最好不要用h5来写页面,兼容性是个头疼的问题,切记切记(移动端可以用H5来 ...