本文主要是介绍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
#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;
}
这篇关于A. Minimize!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!