欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1209A.Paint the Numbers
Paint the Numbers
You are given a sequence of integers . You need to paint elements in colors, so that:
- If we consider any color, all elements of this color must be divisible by the minimal element of this color.
- The number of used colors must be minimized.
For example, it's fine to paint elements in a single color, because they are all divisible by . You can use any color an arbitrary amount of times (in particular, it is allowed to use a color only once). The elements painted in one color do not need to be consecutive.
For example, if then two colors are required: let's paint , and in the first color (, and are divisible by ) and paint and in the second color ( and are divisible by ). For example, if then colors are required (we can simply paint each element in an unique color).
Input
The first line contains an integer (), where is the length of the given sequence.
The second line contains integers (). These numbers can contain duplicates.
Output
Print the minimal number of colors to paint all the given numbers in a valid way.
Note
In the first example, one possible way to paint the elements in colors is:
- paint in the first color the elements: and ,
- paint in the second color the element ,
- paint in the third color the elements: , and .
In the second example, you can use one color to paint all the elements.
In the third example, one possible way to paint the elements in colors is:
- paint in the first color the elements: , and ,
- paint in the second color the elements: , and ,
- paint in the third color the element ,
- paint in the fourth color the element .
Samples
6
10 2 3 5 4 2
3
4
100 100 100 100
1
8
7 6 5 4 3 2 2 3
4
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |