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

SOS:大虾帮忙!!

Posted by cpp050700448084 at 2005-04-03 15:00:15 on Problem 2381
#include <iostream.h>
#include <math.h>
void main()
{
	int a,c,m,j,sum=0;
	cin>>a>>c>>m;
	int *r=new int[m];cin>>r[0];
	for (int i=1;i<m;i++){
		r[i]=(a*r[i-1]+c)%m;
		if(fabs(r[i]-r[i-1])>sum) sum= fabs(r[i]-r[i-1]) ;
		for (j=0;j<i;j++)
			if(r[j]==r[i])
				goto loop;
	}
	loop : cout<<sum<<endl;
	delete []r;
}

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