首页 > 代码库 > zoj 1760
zoj 1760
#include<iostream>
#include<set>
using namespace std;
int main(void)
{
while(true)
{
set<int> s;
int n, doubles = 0;
while(cin>>n && n)
{
if(n == -1)
return 0;
s.insert(n);
if(s.find(2*n) != s.end())
doubles++;
if(n%2 == 0 && s.find(n/2) != s.end())
doubles++;
}
cout<<doubles<<endl;
}
return 0;
}
新波动(754369601) 11:13:03
zoj 1760:
#include <iostream>
#include <map>
#include <string>
using namespace std;
map <string,int>my;
map <string,int>::iterator it;
int main(int argc, char *argv[])
{
int n;string s,s1;int Max;
while(cin>>n,n)
{
Max=0;
while(n--)
{cin>>s;my[s]++;}
for(it=my.begin();it!=my.end();it++)
{
if(Max<(*it).second)
{
Max=(*it).second;
s1=(*it).first;
}
}cout<<s1<<endl;
my.clear();
}
return 0;
}
*********************************************************************************************************************
[--李吉环--]<lijihuan0@qq.com> 11:13:22
zoj ///1760
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<set>
using namespace std;
set <int> s;
set <int>::iterator it;
int main()
{
int x,ans,i;
while(1)
{
ans=0;
s.clear();
while(scanf("%d",&x))
{
if(x==-1)
return 0;
if(x==0)
break;
s.insert(x);
}
for(it=s.begin();it!=s.end();it++)
if(s.find((*it)*2)!=s.end())
ans++;
printf("%d\n",ans);
}
}
*********************************************************************************************************************
新波动(754369601) 11:13:38
zoj 1760:
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
int n,x,a[100],i,j,s,t;
while(cin>>n)
{
a[0]=n;
i=1;s=0;
if(n==-1)break;
while(cin>>x,x)a[i++]=x;t=i;
sort(a,a+t);
for(i=0;i<t-1;i++)
for(j=i+1;j<t;j++)
{
if(a[j]==2*a[i])s++;
}
cout<<s<<endl;
}
return 0;
}