目录

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;
}
本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
whltaoin1 小时前
Java实现N皇后问题的双路径探索:递归回溯与迭代回溯算法详解
java·算法
同勉共进2 小时前
虚函数表里有什么?(二)——普通单继承下的虚函数表
c++·单继承·虚函数表·dynamic_cast·rtii
梭七y3 小时前
【力扣hot100题】(032)排序链表
算法·leetcode·链表
SsummerC3 小时前
【leetcode100】数组中的第K个最大元素
python·算法·leetcode
编程绿豆侠3 小时前
力扣HOT100之链表:206. 反转链表
算法·leetcode·链表
永恒迷星.by4 小时前
文件操作(c语言)
c语言·c++·算法·文件操作
还有你Y4 小时前
MIMO预编码与检测算法的对比
算法·预编码算法
凯强同学5 小时前
第十四届蓝桥杯大赛软件赛省赛Python 大学 C 组:7.翻转
python·算法·蓝桥杯
记得早睡~6 小时前
leetcode51-N皇后
javascript·算法·leetcode·typescript
Zhichao_976 小时前
【UE5 C++课程系列笔记】32——读Json文件并解析
c++·ue5