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

O(∩_∩)O哈哈~这样暴力也能过啊!

Posted by luchenqun at 2010-10-26 20:48:45 on Problem 2769
#include<iostream>
#include<algorithm>
#define MAX 302
using namespace std;

int a[MAX],temp[MAX];

int main()
{
	int T,n,i,j;
	cin>>T;
	while(T--)
	{
		bool flag=true;
		cin>>n;
		for(i=0;i<n;i++)
			cin>>a[i];
		if(n==1)
		{
			cout<<1<<endl;
			flag=false;
		}
		if(flag)
		{
			for(j=1;;j++)
			{
				for(i=0;i<n;i++)
					temp[i]=a[i]%j;
				sort(temp,temp+n);
				for(i=1;i<n;i++)
					if(temp[i-1]==temp[i])
						break;
					if(i==n)
						break;
			}
			cout<<j<<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