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(n)

Posted by lxc902 at 2011-11-21 22:16:34 on Problem 3427
In Reply To:求O(n)的算法 Posted by:Snow_storm at 2010-03-20 15:28:08
#include <iostream>
using namespace std;

int main()
{
	int n,l,t,max=0,i;
	cin>>n>>l;
	for(i=0;i<n;i++){
		cin>>t;
		if(t%l&&l-t%l>max) max=l-t%l;
	}
	cout<<max<<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