F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Building roads

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 233    Accepted Submission(s): 41


Problem Description
There is a circle-shape lake in a beautiful town. And along the lake, there are N cities, living lots of pigs.
In 2008, the number of pigs is growing so faster that the government decide to transfer some pigs from some cities to others. And they want to make that each city has the same number of pigs.
Before the transfer, the government has to build some roads between cities. For example, if we want to move some pigs from city A to city B, we have to build a road between A and B. Now the government wants to save more money for the National's Day, so they want to build roads as few as possible, i.e, they want to know how many roads at least they have to build to make that each city has the same number of pigs.



Giving the initial number of pigs of each city, you should tell me the least number of roads have to build. If it is impossible to make each city has the same number of pigs, output "Impossible".
 

Input
There will be multiple input sets. The first line of input will contain a integer K, means the number of sets.
Input for each set is a positive integer n(means the number of cities, 1 <= n <= 10000) on a line by itself, followed one line containing some positive integers(no more than 10000), indicate the cities' initial number of pigs.
 

Output
Output for each input set should be one line containing a positive integer R, means the least number of roads have to build, output "Impossible" if it is impossible to make each city has the same number of pigs
 

Sample Input
4 3 1 2 3 3 2 2 2 4 1 3 1 3 3 1 3 3
 

Sample Output
1 0 2 Impossible
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 16:30:57, Gzip enabled