Rnadom  Teams

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.actioncid=88890#problem/B

题目:

Description

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.

Input

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.

Output

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.

Sample Input

Input
5 1
Output
10 10
Input
3 2
Output
1 1
Input
6 3
Output
3 6

Hint

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.

分析:

    最大组队数肯定有一队为n-m+1人,最小的为把人数尽可能均分。

即有n%m队为n/m+1,n-n%m队为n/m人,最后算一下朋友对数,

一个队友n人,可以产生n*(n-1)/2队朋友。

#include<iostream>
using namespace std;
int main()
{
long long mi,n,m,ma,x,i=;
cin>>n>>m;
x=n/m;
if(n%m!=)
i=n%m;
mi=(x*(x-)/)*(m-i)+(x*(x+)/)*i;
ma=((n-m+)*(n-m)/);
cout<<mi<<' '<<ma<<endl;
return ;
}

Rnadom Teams的更多相关文章

  1. URAL 1208 Legendary Teams Contest(DFS)

    Legendary Teams Contest Time limit: 1.0 secondMemory limit: 64 MB Nothing makes as old as years. A l ...

  2. timus 1106 Two Teams(二部图)

    Two Teams Time limit: 1.0 secondMemory limit: 64 MB The group of people consists of N members. Every ...

  3. CF478 B. Random Teams 组合数学 简单题

    n participants of the competition were split into m teams in some manner so that each team has at le ...

  4. UVA 11609 Teams 组合数学+快速幂

    In a galaxy far far away there is an ancient game played among the planets. The specialty of the gam ...

  5. SCAU 07校赛 10317 Fans of Footbal Teams

    10317 Fans of Footbal Teams 时间限制:1000MS  内存限制:65535K 题型: 编程题   语言: 无限制 Description Two famous footba ...

  6. "is not on any development teams " Xcode的账号错误问题

    "***@*** is not on any development teams " Xcode现在在"Accounts"中时不时会出现这个提示. 但其他按钮都 ...

  7. cf478B Random Teams

    B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  8. uva 10911 - Forming Quiz Teams(记忆化搜索)

    题目链接:10911 - Forming Quiz Teams 题目大意:给出2 * n个选手的坐标, 要求将所有的选手分成n组, 每组两个人, 所有组的两个人之间的距离之和要最小, 输出最小值. 解 ...

  9. codeforces 478B Random Teams

    codeforces   478B  Random Teams  解题报告 题目链接:cm.hust.edu.cn/vjudge/contest/view.action?cid=88890#probl ...

随机推荐

  1. [Liferay6.2]AUI表单验证示例

    <%@ page contentType="text/html; charset=UTF-8"%> <%@ taglib uri="http://jav ...

  2. HDU 5919 Sequence II 主席树

    Sequence II Problem Description   Mr. Frog has an integer sequence of length n, which can be denoted ...

  3. Android加载大图片OOM异常解决

      尽量不要使用setImageBitmap或setImageResource或BitmapFactory.decodeResource来设置一张大图, 因为这些函数在完成decode后,最终都是通过 ...

  4. JavaScript模拟函数重载

    JavaScript是没有函数重载的,但是我们可以通过其他方法来模拟函数重载,如下所示: <!DOCTYPE html> <html> <head> <met ...

  5. Android 编程下 DP、SP 以及屏幕像素密度

    有时需为视图属性指定大小尺寸值(通常以像素为单位,但有时也用点.毫米或英寸).最常见的属性有: 文字大小(Text Size),指设备上显示的文字像素高度: 边距(Margin),指定视图组件间的距离 ...

  6. AngularJS学习之HTML DOM

    1.AngularJS为HTML DOM元素的属性提供了绑定应用数据的指令: 2.ng-disabled指令:直接绑定应用程序数据到HTML的disable属性: <div ng-app=&qu ...

  7. Codeforces Round #375 (Div. 2) - A

    题目链接:http://codeforces.com/contest/723/problem/A 题意:在一维坐标下有3个人(坐标点).他们想选一个点使得他们3个到这个点的距离之和最小. 思路:水题. ...

  8. SPOJ DISUBSTR 后缀数组

    题目链接:http://www.spoj.com/problems/DISUBSTR/en/ 题意:给定一个字符串,求不相同的子串个数. 思路:直接根据09年oi论文<<后缀数组——出来字 ...

  9. chrome插件

    自备FQ神器,或者在公司浏览谷歌商店.话说我们公司电脑可以打开谷歌商店. 1.Performance-Analyser(网页性能分析) 这款插件是用来分析你的网页加载性能的,包括http请求,执行期的 ...

  10. Java基础语法的学习

    首先就是关于枚举类型的思考与实践,这个是在jdk5.0及以后的版本才有的,然后对枚举类型进行动手操作. 源代码: package test; public class EnumTest { publi ...