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 test(s)
input
5 1
output
10 10
input
3 2
output
1 1
input
6 3
output
3 6
Note

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的更多相关文章

  1. cf478B Random Teams

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

  2. codeforces 478B Random Teams

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

  3. B. Random Teams(Codeforces Round 273)

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

  4. 【CODEFORCES】 B. Random Teams

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

  5. 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 ...

  6. 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 ...

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

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

  8. codeforces 478B Random Teams 解题报告

    题目链接:http://codeforces.com/problemset/problem/478/B 题目意思:有 n 个人,需要将这班人分成 m 个 组,每个组至少含有一个人,同一个组里的人两两可 ...

  9. cf478B-Random Teams 【排列组合】

    http://codeforces.com/problemset/problem/478/B B. Random Teams   n participants of the competition w ...

随机推荐

  1. Vmware虚拟机网络模式及虚拟机与物理机通信方法

    [转]http://www.cqeis.com/news_detail/newsId=1477.html Vmware虚拟机软件是一个“虚拟PC”软件,它使你可以在一台机器上同时运行二个或更多Wind ...

  2. python 爬一下

    1.安装Requestswindow:pip install requestslinux:sudo pip install requests国内安装缓慢,建议到:http://www.lfd.uci. ...

  3. Xamarin.Android开发实践(四)

    原文:Xamarin.Android开发实践(四) Xamarin.Android下获取与解析JSON 一.新建项目 1.新建一个Android项目,并命名为为NetJsonList 2.右击引用,选 ...

  4. cocos2d-x游戏开发系列教程-超级玛丽09-怪物激活与移动

    在游戏中,很多怪物本身是会移动的,这里主要有蘑菇怪,乌龟等. 说起怪物的移动,首先在游戏里先要考虑怪物的抽象和设计. 在CMMonster.h中,有个类CMMonsterBasic,这个类抽象了所有的 ...

  5. POJ 3518 Prime Gap(素数题)

    [题意简述]:输入一个数,假设这个数是素数就输出0,假设不是素数就输出离它近期的两个素数的差值,叫做Prime Gap. [分析]:这题过得非常险.由于我是打的素数表. 由于最大的素数是1299709 ...

  6. stm32之GPIO(二)

    输入上拉:当IO口作为输入时,比如按键输入,而按键是与地连接,按下时为低电平,则没按下时该IO口应为高电平,上拉即是该IO口通过一个电阻与电源相连,则没按下时为高电平,按下即为低电平. 输入下拉:同理 ...

  7. 竖向折叠二级导航JS代码(可防刷新ul/li结构)

    <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    ...

  8. DZNEmptyDataSet框架简介

    给大家推荐一个设置页面加载失败时显示加载失败等的框架. 下载地址:DZNEmptyDataSet https://github.com/dzenbot/DZNEmptyDataSet 上效果首先在你的 ...

  9. set--常见成员函数及基本用法

    c++ stl集合set介绍 c++ stl集合(Set)是一种包含已排序对象的关联容器. set/multiset会根据待定的排序准则,自动将元素排序.两者不同在于前者不允许元素重复,而后者允许. ...

  10. jquery删除动态增加的li

    <script type="text/jscript"> //楼主帮你修改调整了下 $(document).ready(function () { $('.zuo li ...