(以“分类:排序及模拟分类:哈希表 ==摘要== {{信息题|互斥的数|http://www.codevs.cn/problem/1553/|1|100|time=2015-2-3 18:41:18}} ==题意== 给n...”为内容创建页面) |
小 (分类) |
||
| 第1行: | 第1行: | ||
| − | [[分类: | + | [[分类:排序与模拟]][[分类:哈希表]] |
==摘要== | ==摘要== | ||
{{信息题|互斥的数|http://www.codevs.cn/problem/1553/|1|100|time=2015-2-3 18:41:18}} | {{信息题|互斥的数|http://www.codevs.cn/problem/1553/|1|100|time=2015-2-3 18:41:18}} | ||
| 题目链接 | 难度等级 | 完成状态 | 完成分数 | 最后编辑时间 | 需要注意 |
|---|---|---|---|---|---|
| 互斥的数 | ★☆☆☆☆ | 答案正确 | 100 | 2015-2-3 18:41:18 | 无 |
给n个数,删除最少的数,剩下的不存在a,b使得a=P*b;
| 1553.cpp代码已折叠
展开折叠内容
|
|---|
#include<iostream>
#include<set>
#include<cstdio>
#define foreach(i,a) for(typeof((a).begin()) i=(a).begin();i!=(a).end();++i)
using namespace std;
set<int> s;
int n,P,ans;
int main()
{
scanf("%d%d",&n,&P);
for(int i=1,a;i<=n;++i)
{
scanf("%d",&a);
s.insert(a);
}
ans=s.size();
foreach(i,s)
{
int count=1;
while(s.count(P*(*i)))
{
s.erase(P*(*i));
++count;
}
ans-=count/2;
}
printf("%d",ans);
return 0;
}
|