CF1209A】的更多相关文章

You are given a sequence of integers a1,a2,…,an. 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.…
所谓染色,并使同颜色数都能被当前颜色中最小的数整除 也就是说,把能被某个数整除的所有数放在一起为一组,问共有几组 开始我想写个并查集但是很懒,看数据范围小的可怜,那我们写个暴力看看 因为每组的共因数都是本组最小,那就先从小到大排序 枚举每个没被标记过的数,从这个数开始往后找,碰到能被他整除的就打标记 然后计数器加一 最后输出就好了 #include<iostream> #include<cstdlib> #include<cstring> #include<cst…