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

一次0MS就AC,分享下代码

Posted by zjc0823 at 2010-04-14 11:01:17 on Problem 1552
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int i,j,x[20],leight,num;
	while(cin>>x[0])
	{
		if(x[0]==-1)
			break;
		num=0;
		leight=1;
		while(cin>>x[leight])
		{
			if(x[leight]==0)
				break;
			leight++;
		}
		sort(x,x+leight+1);
		for(i=0;i<leight;i++)
			for(j=i+1;j<=leight;j++)
				if(2*x[i]==x[j])
					num++;
		cout<<num<<endl;
	}
	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