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: | ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TEXT WHITESPACE |
Nguồn bài: | VNOI Marathon '08 - Round 8/DivB Problem Setter: Ngô Minh Đức |