PDP-27 (2015) - Phase C' - 1 (aces)

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

Number Groups

We say that two natural numbers are in the same group when they have the same number of ones (1) in their binary representation. For example, 5 and 17 are in the same group because 5 = 101_{(2)} and 17 = 10001_{(2)}, so both numbers have two ones in their binary representation. On the contrary, 17 and 42 belong to different groups.

Problem

Write a program in one of the IOI languages that reads a sequence of N numbers and then finds the number of members in the largest group that can be formed from terms of the sequence. The sequence may contain equal terms, and in this case, you should include all equal terms in the same group.

Input Files:

The input files named aces.in are text files consisting of two lines: The first line contains exactly one integer: the number N of numbers in the sequence (1 \le N \le 1.000.000). The second line contains N integers A\mathbf{_i} (0 \le A_i \le 1.000.000.000), separated in pairs by a single space: the terms of the sequence.

Output Files:

The output files named aces.out are text files consisting of exactly one line containing exactly one integer: the number of members in the largest group consisting of terms from the sequence.

Example of Input - Output Files:

STDIN (aces.in)

6
1 2 4 3 2 5

STDOUT (aces.out)

4

Explanation: In the largest group belong: 1, 2 (twice), and 4, which have one '1' in their binary representation.

Formatting: In the output, each line terminates with a newline character.
Maximum execution time: 1 sec.
Maximum available memory: 16 MB.


Comments

There are no comments at the moment.