您的位置:首页 > 其它

poj 1552 Doubles

2011-07-18 11:23 323 查看
#include <iostream>
#include <algorithm>
using namespace std;
int top,list[16];
bool db(int i)
{
int j;
for( j=i+1;j<top;j++)
if(list[j]>=2*list[i])
break;
if(list[j]==2*list[i])
return true;
return false;
}
int main()
{
int a,s,i;
while(cin>>a&&a!=-1)
{
list[0]=a;top=1;
while(cin>>a&&a)
list[top++]=a;
sort(list,list+top);
s=0;
for(i=0;i<top-1;i++)
if(db(i))
s++;
cout<<s<<endl;
}
return 0;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: