CF1539A Contest Start

题目描述

There are nn people participating in some contest, they start participating in xx minutes intervals. That means the first participant starts at time 00 , the second participant starts at time xx , the third — at time 2 \cdot x2⋅x , and so on.

Duration of contest is tt minutes for each participant, so the first participant finishes the contest at time tt , the second — at time t + xt+x , and so on. When a participant finishes the contest, their dissatisfaction equals to the number of participants that started the contest (or starting it now), but haven't yet finished it.

Determine the sum of dissatisfaction of all participants.

输入格式

The first line contains a single integer kk ( 1 \le k \le 10001≤k≤1000 ) — the number of test cases.

Each of the next kk lines contains three integers nn , xx , tt ( 1 \le n, x, t \le 2 \cdot 10^91≤n,x,t≤2⋅109 ) — the number of participants, the start interval and the contest duration.

输出格式

Print kk lines, in the ii -th line print the total dissatisfaction of participants in the ii -th test case.

题意翻译

题意描述

有 nn 个人参加某个竞赛,他们以 xx 分钟的间隔开始。

每个参赛者的比赛时长为 tt 分钟,因此第一个参赛者在 tt 时间结束比赛,第二个参赛者在 t+xt+x 时间结束比赛,依此类推。当一个参赛者完成比赛时,他们的不满意程度等于已开始比赛(或现在正好开始)但还没有完成比赛的参赛者人数。

求所有参赛者的不满意程度之和。

输入格式

第一行包含一个整数 kk ( 1\leq k\leq 10001≤k≤1000),表示数据组数。

接下来的每一行包含三个整数 n,x,tn,x,t ( 1\leq n,x,t\leq 2⋅10^91≤n,x,t≤2⋅109),分别为参与者的数量,开始时间间隔和比赛时长。

输出格式

一共 kk 行,在第 ii 行中输出第 ii 组数据中参与者的不满意程度之和。

输入输出样例

输入 #1复制

4
4 2 5
3 1 2
3 3 10
2000000000 1 2000000000

输出 #1复制

5
3
3
1999999999000000000

说明/提示

In the first example the first participant starts at 00 and finishes at time 55 . By that time the second and the third participants start, so the dissatisfaction of the first participant is 22 .

The second participant starts at time 22 and finishes at time 77 . By that time the third the fourth participants start, so the dissatisfaction of the second participant is 22 .

The third participant starts at 44 and finishes at 99 . By that time the fourth participant starts, so the dissatisfaction of the third participant is 11 .

The fourth participant starts at 66 and finishes at 1111 . By time 1111 everyone finishes the contest, so the dissatisfaction of the fourth participant is 00 .

In the second example the first participant starts at 00 and finishes at time 22 . By that time the second participants starts, and the third starts at exactly time 22 . So the dissatisfaction of the first participant is 22 .

The second participant starts at time 11 and finishes at time 33 . At that time the third participant is solving the contest.

     //思路:计算第一个人的比赛时间 与第二个人的间隔时间的大小 如果比他的时间短 则sum++
    //如果不比他短 则用这个人的前一个人的间隔时间加比赛时间进行比较 如果前一个人的时间比他后面的人短 则0有几个人符合这种情况就加几个人 
    
    //困难的地方:如何用代码实现 使用数组存起来还是for循环
    //我认为 如果用for循环 不知道怎么将这些数进行比较 如果用数组 我觉得没必要 因为比赛时长是固定相同的数

#include<bits/stdc++.h>
using namespace std;
long long int k,n,x,t,tmp,sum;

int main()
{
	//思路:计算第一个人的比赛时间 与第二个人的间隔时间的大小 如果比他的时间短 则sum++
	//如果不比他短 则用这个人的前一个人的间隔时间加比赛时间进行比较 如果前一个人的时间比他后面的人短 则0有几个人符合这种情况就加几个人 
	
	//困难的地方:如何用代码实现 使用数组存起来还是for循环
	//我认为 如果用for循环 不知道怎么将这些数进行比较 如果用数组 我觉得没必要 因为比赛时长是固定相同的数 
	cin>>k;
	while(k--)
	{
		cin>>n>>x>>t;
		tmp=t/x;//不满意程度最大的人数
		sum=0;
		if(n<tmp)//3 3 2的情况 
		{
			sum=n*(n-1)/2;
			cout<<sum<<endl;
			continue;
		}
		sum=sum+(1+tmp)*tmp/2;// 10 2 10的情况
		n=n-(1+tmp);
		cout<<sum+n*tmp<<endl;	
	} 
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值