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

why wa?高手指点

Posted by tangw at 2007-03-02 01:56:03 on Problem 2769
#include<iostream>
using namespace std;
int tag[1000000];
int main()
{
	int n,g,num[300],i,j;
	cin>>n;
	while(n--){
		cin>>g;
		for(i=0; i<g; i++)
			cin>>num[i];
		if(g==1)
			cout<<1<<endl;
		else{
			for(j=g; j<1000000 ;j++){
				for(i=0; i<g; i++){
					int temp = num[i]%j;
					if(tag[temp]==j)
						break;
					else
						tag[temp] = j;
				}
				if(i==g){
					cout<<j<<endl;
					break;
				}
			}
		}
	}
	system("pause");
    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