Sunday 11 October 2015

Doubles (UVALive 2787, HDU 1303, ZOJ 1760, POJ 1552, Regionals 2003 >> North America - Mid-Central USA)

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100000


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1, n, arr[20], x;
    bool exist[202];
    string s;
    char ch;
    while(cin>>x && x!=-1)
    {
        int n=0;
        arr[n++]=x;
        CLR(exist);
        exist[x]=true;
        while(cin>>x && x)
        {
            arr[n++]=x;
            exist[x]=true;
        }
        int cnt=0;
        for(int i=0;i<n;i++)
            if(exist[arr[i]*2])
                cnt++;
        cout<< cnt <<"\n";
    }
return 0;
}

No comments:

Post a Comment