Rnadom Teams
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
- 5 1
- 10 10
- 3 2
- 1 1
- 6 3
- 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的更多相关文章
- 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 ...
- timus 1106 Two Teams(二部图)
Two Teams Time limit: 1.0 secondMemory limit: 64 MB The group of people consists of N members. Every ...
- CF478 B. Random Teams 组合数学 简单题
n participants of the competition were split into m teams in some manner so that each team has at le ...
- UVA 11609 Teams 组合数学+快速幂
In a galaxy far far away there is an ancient game played among the planets. The specialty of the gam ...
- SCAU 07校赛 10317 Fans of Footbal Teams
10317 Fans of Footbal Teams 时间限制:1000MS 内存限制:65535K 题型: 编程题 语言: 无限制 Description Two famous footba ...
- "is not on any development teams " Xcode的账号错误问题
"***@*** is not on any development teams " Xcode现在在"Accounts"中时不时会出现这个提示. 但其他按钮都 ...
- cf478B Random Teams
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- uva 10911 - Forming Quiz Teams(记忆化搜索)
题目链接:10911 - Forming Quiz Teams 题目大意:给出2 * n个选手的坐标, 要求将所有的选手分成n组, 每组两个人, 所有组的两个人之间的距离之和要最小, 输出最小值. 解 ...
- codeforces 478B Random Teams
codeforces 478B Random Teams 解题报告 题目链接:cm.hust.edu.cn/vjudge/contest/view.action?cid=88890#probl ...
随机推荐
- ASP.NET 5 Beta7发布
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 前几天,ASP.NET 5如期发布了Beta 7,根据路线图 (https://github ...
- MySQL5.5出面ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题的解决办法
问题描述 安装完MySQL5.5数据库,使用Navicat Premium以及命令窗口连接数据库都报以下错误: ERROR 1045 (28000): Access denied for user ' ...
- MFC 丢失MSVCR120D.dll 丢失mfc120ud.dll
- 锤子banner
查看效果: http://js.jirengu.com/negor/4/edit?html,output <!DOCTYPE html> <html> <head> ...
- background为圆角的表框,dp转Px,Px转dp
圆角边框<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="ht ...
- jsp遍历、循环
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 1. <% Te ...
- TCP拆包粘包之分隔符解码器
TCP以流的方式进行数据传输,上层的应用协议为了对消息进行区分,往往采用如下4种方式. (1)消息长度固定,累计读取到长度总和为定长LEN的报文后,就认为读取到了一个完整的消息:将计数器置位,重新开始 ...
- hdu1213 并查集(不压缩)
确定比赛名次 Problem Description 有N个比赛队(1<=N<=500),编号依次为1,2,3,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名 ...
- DSP using MATLAB 示例 Example3.11
用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...
- [工作中的设计模式]建造者模式builder
一.模式解析 建造模式是将复杂的内部创建封装在内部,对于外部调用的人来说,只需要传入建造者和建造工具,对于内部是如何建造成成品的,调用者无需关心. 以上是对建造者模式的官方定义,简单说就是对于复杂对象 ...