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 ...
随机推荐
- QQ互联OAuth
/** * QQ互联 oauth * @author dyllen * */ class Oauth { //取Authorization Code Url const PC_CODE_URL = ' ...
- PMP 第六章 项目时间管理
定义活动 排列活动顺序 估算活动资源 估算活动持续时间 制定进度计划 控制进度计划 1.进度管理计划和进度计划的内容分别是什么,有什么区别? 进度计划:项目各活动计划完成日期的编排. 进度管理计 ...
- Java学习随笔1:Java是值传递还是引用传递?
Java always passes arguments by value NOT by reference. Let me explain this through an example: publ ...
- 【hibernate merge】session1.merge(T entity)方法的含义和update方法的区别
注意: MERGE语句是SQL语句的一种.在SQL Server.Oracle数据库中可用,MySQL.PostgreSQL中不可用. 1>session1.merge(T entity) 合 ...
- winmail服务器启动失败 无法启动
1.解决句柄问题:打开命令行:开始 -> 运行-> 输入 cmd -> 确定.切换命令目录至winmail的服务目录,我的是:E:\htdocs\Winmail\server\> ...
- Chage
For many times,i've given my own a new lifestyle,such as don't stay up late,have breakfast......whil ...
- Thymeleaf 常用属性
Thymeleaf 常用属性 如需了解thymeleafThymeleaf 基本表达式,请参考<Thymeleaf 基本表达式>一文 th:action 定义后台控制器路径,类似<f ...
- 当 NSDictionary 遇见 nil
Demo project: NSDictionary-NilSafe 问题 相信用 Objective-C 开发 iOS 应用的人对下面的 crash 不会陌生: *** -[__NSPlacehol ...
- iOS 查找文件、遍历文件系统
NSFileManager *manager = [NSFileManager defaultManager]; NSString *home = [@"~" stringByEx ...
- POJ3469 Dual Core CPU(最小割)
形象生动的最小割.. #include<cstdio> #include<cstring> #include<queue> #include<algorith ...