Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
NUMBERS - Những con số |
English | Vietnamese |
Numbers
In a website for mathematical lovers, there is a puzzle as following: given N positive integers, you have to color each number so that each number is not divided by a number that has the same color and the number of used colors is minimized.
Finding this puzzle interesting, Bom asks for your help to solve it! Write a program that help Bom solve this puzzle.
Input
- Line 1: a positive integer N.
- Line 2: N positive integers a1, a2, a3, ..., an.
Output
- Line 1: a positive integer K that is the minimum number of used color.
- In the ith line of the next K lines, write a number ci indicating how many numbers of color i following by ci numbers of color i.
Constraints
- N belongs to [1, 50000]
- ai belongs to [1, 106]
Note
If there are several ways to color the numbers, print any of them.
Example
Input 10 24 7 42 8 2 16 22 21 33 11 Output 3 3 7 2 11 4 8 22 21 33 3 24 42 16
Được gửi lên bởi: | Jimmy |
Ngày: | 2008-07-18 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET |
Nguồn bài: | VNOI Marathon '08 - Round 8/DivB Problem Setter: Ngô Minh Đức |
hide comments