URAL - 2025 Line Fighting

Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u

 Status

Description

Boxing, karate, sambo… The audience is sick of classic combat sports. That is why a popular sports channel launches a new competition format based on the traditional Russian entertainment called line fighting. There can be from 2 to   k  teams taking part in a competition, and there are   n  fighters altogether in all the teams. Before the competition starts, the fighters are divided into teams: each fighter becomes a member of exactly one team. Two fighters fight each other if they are members of different teams. The organizers believe that the more the number of fights between fighters, the higher the popularity of a competition will be. Help the organizers to distribute fighters between teams so as to maximize the number of fights and output this number.

Input

The first line contains the number of tests   T  (1 ≤   T  ≤ 10). In each of the following   T  lines you are given a test: integers   n  and   k  separated with a space (2 ≤   k  ≤   n  ≤ 10   4).

Output

For each test output the answer (one integer) in a separate line.

Sample Input

input output
3
6 3
5 5
4 2
12
10
4

n人分为k组对决,同组不对决,求最多能有几次对决。

k组人数尽量平均,各组间对决次数为各自人数的乘积,枚举累计就好了。

#include<iostream>
using namespace std;
const int MAXN=10010;
long long int t[MAXN];
int main()
{
	long long int n,k;
	int casen;
	cin>>casen;
	while(casen--)
	{
	cin>>n>>k;
	long long int num=n/k;
	for(int i=0;i<k;i++)
		t[i]=num;
	long long int yu=n%k;
	long long int i=0;
	while(yu--)
		t[i++]++;
    int sum=0;
	for(int i=0;i<k;i++)
	for(int j=i+1;j<k;j++)
		sum=sum+t[i]*t[j];
	cout<<sum<<endl;
	}
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

这波lucio来全学了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值