Sphere Online Judge

SPOJ Problem Set (classical)

2148. Candy III

Problem code: CANDY3

A class went to a school trip. And, as usually, all N kids have got their backpacks stuffed with candy. But soon quarrels started all over the place, as some of the kids had more candies than others. Soon, the teacher realized that he has to step in: "Everybody, listen! Put all the candies you have on this table here!"

Soon, there was quite a large heap of candies on the teacher's table. "Now, I will divide the candies into N equal heaps and everyone will get one of them." announced the teacher.

"Wait, is this really possible?" wondered some of the smarter kids.

Problem specification

You are given the number of candies each child brought. Find out whether the teacher can divide the candies into N exactly equal heaps. (For the purpose of this task, all candies are of the same type.)

Input specification

The first line of the input file contains an integer T specifying the number of test cases. Each test case is preceded by a blank line.

Each test case looks as follows: The first line contains N : the number of children. Each of the next N lines contains the number of candies one child brought.

Output specification

For each of the test cases output a single line with a single word "YES" if the candies can be distributed equally, or "NO" otherwise.

Example

Input:
2

5
5
2
7
3
8

6
7
11
2
7
3
4

Output:
YES
NO
Note: the input file will not exceed 1MB.
Added by:[Trichromatic] XilinX
Date:2007-12-01
Time limit:1s-2s
Source limit:50000B
Languages:All except: C99 strict CLOJ ERL F# JS PERL 6 TECS
Resource:IPSC 2006

hide comments
2010-07-05 22:25:07 navin
i used Big integer still i got NZEC. help me pls
2010-06-30 20:16:25 Carlos Toribio
C\C++ users INPUT NUMBERS EXCEEDING 2^63 need of BIG INT
2010-06-23 18:54:06 Rohit Dureja
Hey. i am getting runtime error(NZEC) in this problem. I have used Python. Please help. How to get rid of this error?
2010-06-21 12:21:04 Mohamed Maher
is there any thing wrong in problem
2010-04-19 05:06:55 ~!(*(@*!@^&
Hi, i am the 1234th people who AC this problem ^^.
2010-03-12 17:24:57 .::: Debanjan :::.
C/C++ users should use long long and modular operation :-)
2009-09-17 13:50:26 Ahmed Kotb
simpler in python :)

Last edit: 2009-09-17 13:51:17
2009-07-21 18:38:02 Drew Saltarelli
the input is very, very large. C/C++ users be careful with how you handle it.
2009-07-21 09:37:07 Sura
its very simple while using java BigInteger!!
2009-07-12 21:12:48 Bill the Lizard
The input file isn't parsing as described in the problem.
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.