CF478B.Random Teams
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
有 n 名参赛者以某种方式被分成了 m 个队伍,使得每个队伍至少包含一名参赛者。比赛结束后,来自同一队伍的每一对参赛者都成为了朋友。
你的任务是编写一个程序,计算比赛结束时可能形成的“朋友对”数的最小值和最大值。
输入格式
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.
输入仅有一行,包含两个整数 n 和 m,以单个空格分隔(1 ≤ m ≤ n ≤ 109)——分别表示参与者人数和队伍数量。
输出格式
The only line of the output should contain two integers k__min and k__max — the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.
输出仅包含一行,应包含两个整数 kmin 和 kmax —— 分别表示朋友对的最小可能数量和最大可能数量。
输入输出样例
输入#1
5 1
输出#1
10 10
输入#2
3 2
输出#2
1 1
输入#3
6 3
输出#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.
在第一个样例中,所有参与者都进入同一支队伍,因此恰好会形成十对朋友关系。
在第二个样例中,在任何可能的分组方式下,总有一支队伍恰好有两名参与者,另一支队伍恰好有一名参与者。因此,朋友对的数量恒为一。
在第三个样例中,若将参与者划分为若干支两人队伍,则新形成的友谊对数达到最小值;若将参与者划分为人数分别为 1、1 和 4 的三支队伍,则新形成的友谊对数达到最大值。
输入解题思路,AI测评打分。不知道怎么写?