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:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.4, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.