Contest Start

There are n people participating in some contest, they start participating in x minutes intervals. That means the first participant starts at time 0, the second participant starts at time x, the third — at time 2⋅x, and so on.

Duration of contest is t minutes for each participant, so the first participant finishes the contest at time t, the second — at time t+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.

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

Each of the next k lines contains three integers n, x, t (1≤n,x,t≤2⋅109) — the number of participants, the start interval and the contest duration.

Output
Print k lines, in the i-th line print the total dissatisfaction of participants in the i-th test case.

Example
input
4
4 2 5
3 1 2
3 3 10
2000000000 1 2000000000
output
5
3
3
1999999999000000000

Title description:
There are n people participating in certain games, and they participate in a game every x minutes. This means that the first player, at time 0, starts playing the first game. The second player starts the second game at time x. The third participant is at time 2*x, and so on.

The duration of each contestant's game is t minutes, so the first contestant ends the game at time t. The second player ends the game at time t+x. So on and so forth. When a competitor finishes a race, they will have a dissatisfaction value equal to the number of competitors who were still racing (or were about to start) but hadn't finished the race when that person finished.

Now let you calculate what is the sum of the dissatisfaction values ​​​​of all people when everyone finishes the game.

The Input
title contains multiple sets of samples.
Enter an integer k on the first line, indicating the number of samples.
For each sample, enter three integers n, x, t (1≤ n,x,t ≤ 2e9) on a line — —The meaning of the letter corresponds to the letter of the above question, because the answer may be very large, so it is recommended to use the long long data type.

Output
For each group of samples, output an integer on one line, representing the sum of the dissatisfaction values ​​of all people.

Example
Input
4
4 2 5
3 1 2
3 3 10
2000000000 1 2000000000
Output
5
3
3
1999999999000000000

In this question, it is not difficult to find that when the time interval between the start of each game is greater than the test time, the total anger value is 0, and if they are equal, the total anger value is n-1. In the last case, we can also find out in continuous derivation, we only need Find out what is the anger value of the first person when he leaves the examination room, then the anger value of the i-th person is also the same, and after the i-th person, the anger value begins to decrease slowly, decreasing by 1 each time, until The last person is reduced to 0, and what is the anger value of the first person, the i-th person will start to decrease from the anger value, so we only need to ask for the middle one, plus the last one to find out The sum of their anger points If
you have an idea, go directly to the code:

#include <iostream>
#include <cstdio>
#define ll long long

using namespace std;

ll k,n,x,t,ans;

int main () {
    
    
	scanf("%lld",&k);
	while ( k-- ) {
    
    
		ans = 0;
		scanf("%lld %lld %lld",&n,&x,&t);
		if(x > t) {
    
    //小于就等于0
			cout << "0\n";
			continue;
		}
		else {
    
    
			ll s = t / x;
			if(n > s)//如果递减不是从第一个人开始,就把两部分的加起来
				ans = ( n - s ) * s + s * ( s - 1) / 2;
			else//如果递减从第一个人就开始,那就不用求相等的
				ans = n*(n-1)/2;
			printf("%lld\n",ans);
		}
	}
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_48627750/article/details/119494462