All submissions for this problem are available.Mr.Chef is a chef in a Multi-cuisine restaurant and gives out candies to the children of his guests. At the beginning of the day, Chef is handed a guest list which contains a list of visiting families. Chef produces $N$ candies daily. $N$ *is the number of families* visiting the restaurant. Find out how many candies he is left with after dividing the candies equally among the visiting children where each child gets at least one candy. If it is not possible then find out how many more he needs. *Note - Chef tries to keep the least amount of candies with himself.* ###Input: - The first line will contain $T$, the number of test cases. - The second line will contain $N$, the number of families. - The next $N$ lines contain $A$ and $C$ denoting number adults and children. ###Output: - A single number denoting how many candies he has to make or have in excess. ###Constraints - $1 \leq T \leq 10$ - $1 \leq N \leq 1000$ - $1 \leq A \leq 100$ - $0 \leq C \leq 100$ ###Subtasks - 100 points: $Original Constraints$ ###Sample Inputt: 2 5 2 1 2 0 5 1 1 2 1 0 2 2 2 1 3 ###Sample Output: 1 3 ###EXPLANATION: $Case 1$ Total number of families = 5 Total number of children = 4 Chef is left with one candy after dividing equally. $Case 2$ Total number of families = 2 Total number of children = 5 Chef needs 3 more candies to divide them equally.
|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, rust, SCALA, swift, 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, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.