Lucky thief

 avatar
user_3763047219
c_cpp
2 years ago
366 B
2
Indexable
Never
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<stdlib.h>

int main()
{
	int n = 0;
	scanf("%d", &n);
	while (n--) {
		long long int key, door;
		scanf("%lld %lld", &key, &door);
		long long int ans ;
		ans = ((door - 1) + (door - key)) * key / 2;
		//第一把鑰匙試n扇門,會失敗n-1次
		printf("%lld\n", ans);
	}
	return 0;
}