A. Minimize!

time limit per test

1 second

memory limit per test

256 megabytes

You are given two integers aa and bb (a≤ba≤b). Over all possible integer values of cc (a≤c≤ba≤c≤b), find the minimum value of (c−a)+(b−c)(c−a)+(b−c).

Input

The first line contains tt (1≤t≤551≤t≤55) --- the number of test cases.

Each test case contains two integers aa and bb (1≤a≤b≤101≤a≤b≤10).

Output

For each test case, output the minimum possible value of (c−a)+(b−c)(c−a)+(b−c) on a new line.

Example

Input

Copy

复制代码

3

1 2

3 10

5 5

Output

Copy

复制代码
1
7
0

Note

In the first test case, you can choose c=1c=1 and obtain an answer of (1−1)+(2−1)=1(1−1)+(2−1)=1. It can be shown this is the minimum value possible.

In the second test case, you can choose c=6c=6 and obtain an answer of (6−3)+(10−6)=7(6−3)+(10−6)=7. It can be shown this is the minimum value possible.

解题说明::水题,结果就是b-a

cpp 复制代码
#include <stdio.h>

int main() 
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%d\n", b - a);
	}
	return 0;
}
相关推荐
YGGP14 分钟前
【Golang】LeetCode 19. 删除链表的倒数第 N 个节点
算法·leetcode·链表
枫叶丹415 分钟前
【Qt开发】Qt系统(三)->事件过滤器
java·c语言·开发语言·数据库·c++·qt
池塘的蜗牛21 分钟前
mmse-based-OFDM-signal-processing(2)
算法
Kris_LinSD30 分钟前
算法小实验——分治算法快速排序问题实验(含报告)
c语言·算法
Super小白&31 分钟前
十大经典排序算法详解(附C语言实现+复杂度分析)
c语言·算法·排序算法
Eloudy31 分钟前
Birkhoff 多胞形,双随机矩阵的几何世界
算法
2503_9469718637 分钟前
【SystemDesign/HA】2025年度高可用分布式仿真节点与预测模型容灾演练配置 (Disaster Recovery Config)
大数据·分布式·算法·系统架构·数据集
GrowingYi37 分钟前
算法基础技术栈
数据结构·算法
坐怀不乱杯魂43 分钟前
Linux - 缓存利用率
linux·c++·缓存
炽烈小老头43 分钟前
【 每天学习一点算法 2026/01/04】打家劫舍
学习·算法