Chef and Inequality
All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef likes inequalities. Please help him to solve next one.
Given four integers a, b, c, d. Find number of solutions x < y, where a ≤ x ≤ b and c ≤ y ≤ d and x, y integers.
The first line contains an integer T denoting number of tests.
First line of each test case contains four positive integer numbers a, b, c and d.
For each test case, output a single number each in separate line denoting number of integer solutions as asked in the problem.
- 1 ≤ T ≤ 20
- 1 ≤ a, b, c, d ≤ 106
- Subtask #1: (30 points) 1 ≤ a, b, c, d ≤ 103.
- Subtask #2: (70 points) Original constraints.
Input: 1 2 3 3 4 Output: 3 Input: 1 2 999999 1 1000000 Output: 499998500001
|Tags||basic-math, cakewalk, ltime40, mgch|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.