Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水过~

Posted by yingxiang720 at 2011-03-17 10:17:08 on Problem 1552
#include <iostream>
#include <algorithm>
using namespace std;

double a[100];

bool cmp(double a,double b)
{
    return a < b;
}
int main()
{
    int i,co;
    while(scanf("%lf",&a[0]) && a[0] != -1)
    {
        i = 1;
        co = 0;
        while(scanf("%lf",&a[i]) && a[i] != 0)   i++;
        sort(a,a + i,cmp);
        for(int ci = 0; ci < i;ci++)
            for(int j = ci + 1;j < i;j++)
            {
                if(a[ci] == a[j] / 2)
                    co ++;
            }
        printf("%d\n",co);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator