Back to Category
d257: [12.10] C - Princess’s Marriage

Difficulity: N/A | Test Data Sets: 1 (Hidden) | Judging: Traditional Judge
Accepted : 4 Times | Submit :23 Times | Clicks : 472
Accepted : 4 Users | Submit : 6 Users | Accepted rate : 67%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
Update : 2013-01-16 21:50


Once upon a time, there was a beautiful princess in the Palace of Tremendous Castle (PTC for short). She was not only pretty but also very talented. It’s the dream for every warrior in PTC to marry her. There was a sandy beach in PTC where was full of uneven size and colourful seashells. The princess loved to collect seashells and already had a fortune of them.

The time came for the princess to marry, and the king set his heart on finding the best husband for his daughter. Because of the significance of the decision, and also because the king was very superstitious, he consulted a fortune-teller for advice. The fortune-teller came up with an eccentric method of choosing a husband: all candidates must pass an IQ test and a one warrior left, but he still needed a bit of luck to ask for the princess’s hand in marriage. He was given the test of filling a number of sacks with all the seashells the princess had collected, using all of the sacks in the process.

The sacks were originally weighted the same, and if the warrior could make them weigh equally after filling them with seashells, then he must have been destined to marry the princess. If not, then he too, would be eliminated. Can you determine if the warrior and the princess will tie the knot?

Technical Specifications
  1. The number of sacks M is at least 2 and no more than 10.
  2. The number of seashells N would satisfy 2 ≤ M ≤ 100
  3. Each seashell weight no more than 10000.


The first line of the input file contains an integer indicating the number of test cases to follow. Each test case starts with two integers M and N, separated by spaces and follows by N positive integers each also separated by spaces. 


For each test case, output Congratulations in a line if the warrior can marry the princess, and NO otherwise.

Sample Input:help

若題目沒有特別說明,則應該以多測資的方式讀取,若不知如何讀取請參考 a001 的範例程式。
4 4 1 1 1 1
4 5 10 20 30 40 50
5 10 1 6 2 5 3 4 4 3 5 2

Sample Output :


Hint :

click here to download the problem solving hint

Author :

  Solve it!   Status Forum

57910. rocky61614
(12ms, 160KB, 1273B)
46721. rabbit125
(0ms, 702KB, 1752B)

Program running time may be affected by various factors. Check server system environment information here