Number statistics
Time Limit: 2000 MS | memory limit: 65535 KB difficulty: 2
-
Description
-
Zyc is boring recently, so he wants to make a boring statistical analysis. He counted the addresses of all the students (zyc converted the addresses into code), and then he wanted to know the most students in that place (if there are multiple students with the most students, ).
-
-
Input
-
Enter a positive integer T (0 <T <= 11) in the first line to indicate that there are T groups of test data.
Enter a positive integer N (0 <N <200000) In the first line of each group of test data to indicate that there are N numbers, and then enter N encodings (the encoding is composed of digits and less than 10 digits)
-
-
Output
-
The output of each group of data occupies the maximum number of output rows
Sample Input
1
5
12345 456 45 78 78
Sample output
78
Code:
# Include <cstdio> # include <algorithm> # include <iostream> # include <cstring> using namespace std; int main () {int max = 0, a [200003]; int n, m, I, ac; int count = 0; scanf ("% d", & n); while (n --) {scanf ("% d ", & m); for (I = 1; I <= m; I ++) scanf ("% d", & a [I]); max = 1; // The maximum value is at least 1 sort (a + 1, a + m + 1 ); // sort the numbers from 1 to m in the following Table // for (I = 1; I <= m; I ++) // printf ("% d", a [I]); // printf ("\ n = \ n"); if (m = 1) {printf ("% d \ n", a [1]); continue;} ac = a [1]; for (I = 2; I <= m ;) {count = 1; while (a [I] = a [I-1] & I <= m) // compare the number of I and the previous one, if not, keep accumulating {count ++; I ++;} if (count> max) // The maximum number of records and the corresponding number {max = count; ac = a [I-1];} I ++; // go to another number} printf ("% d \ n", ac);} return 0 ;}