#P1097. [NOIP 2007 提高组] 统计数字

[NOIP 2007 提高组] 统计数字

Description

In a research survey, nn natural numbers were collected, each not exceeding 1.5×1091.5 \times 10^9. It is known that the number of distinct values does not exceed 10410^4. Now you need to count how many times each natural number appears and output the results in ascending order of the numbers.

Input Format

There are n+1n+1 lines in total.

  • The first line contains an integer nn, the number of natural numbers.
  • Lines 22 to n+1n+1 each contain one natural number.

Output Format

Output mm lines in total (where mm is the number of distinct numbers among the nn natural numbers), in ascending order of the numbers.

Each line outputs 22 integers: the natural number and the number of times it appears, separated by a single space.

8
2
4
2
4
5
100
2
100
2 3
4 2
5 1
100 2

Hint

  • 30% of the testdata satisfy: 1n10001 \le n \le 1000.
  • 60% of the testdata satisfy: 1n500001 \le n \le 50000.
  • 100% of the testdata satisfy: 1n2000001 \le n \le 200000, and each number does not exceed 1.5×1091.5 \times 10^9.

NOIP 2007 Senior, Problem 1.

Translated by ChatGPT 5