Is there any trick to handle very very large inputs in C++? -


A class went to a school trip and, as usual, all n children with candy Your backpacks have been filled but soon the fight started everywhere, because some children had more candy than others. Soon, the teacher realized that she would have to move forward: "Everyone, listen! Here you have all the candies available on this table!"

Soon, the teacher had a huge pile of candies on the table. "Now, I will divide the candies in a heap equal to N and all of them will get one of them." Teacher announced.

"Wait, is this really possible?" Thought about some clever children.

Problem Specification

You are given the number of candies brought to each child. Find out if the teacher can pile candy equally in N (For the purpose of this work, all candies are of the same type.)

Input Specification

An integer that specifies the number of test cases in the first line of the input file T is there. Each test case has been placed before a blank line.

The case for each exam looks like this: In the first line N: The number of children is one of the children in the next N lines brought to the candies.

Output Specification

Each test can be distributed evenly to one word "yes" candies, or "no" otherwise.

example

Input:

  2 5 5 6 7 11 2 7 3 4  
< P> Output:

  Yes No  

The problem is simple but the case is that SPOJ judges are using very very big information I have used the unsigned long datatype, yet it shows wc.

Here is my code:

  # include & lt; Iostream & gt; using namespace std; Int main () {Unsigned Long C = 0, N, K, J, Testcase, Yoga = 0, i; Four b [10000] [10]; CIN & gt; & Gt; Testcases; While (testcases -> gt; 0) {sum = 0; CIN & gt; & Gt; N; J = n; While (j -> 0) {cin & gt; & Gt; Of; Yoga + = k; } If (amount% n == 0) {b [c] [0] = 'y'; B [c] [1] = 'e'; B [c] [2] = 's'; B [c] [3] = '\ 0'; C ++; } And {b [c] [0] = 'n'; B [c] [1] = 'o'; B [c] [2] = '\ 0'; C ++; }} For (i = 0; i & lt; c; i ++) cout & lt; & Lt; "\ N" & lt; & Lt; B [i]; Return 0; }  

Easy. Do not increase the number of candies; Instead, keep the number of children, the number of candies per child. ( CCK ), and a count of additional candies ( CEC .) When you read a new line, ck + = 1; cc + = new candies, if (CEC & Gt; CK) CCK + = (CEC / CK) CEC% = CK;


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -