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

Re:转载 算法

Posted by jsmingzi at 2009-02-06 21:38:14 on Problem 3517
In Reply To:Re:转载 算法 Posted by:jsmingzi at 2009-02-06 21:36:12
我也是用这种算法,但是第二组数据就是通不过,为什么呢?真是太郁闷了!!!!!!!
#include<iostream>
using namespace std;

int main()
{
	int n,m,k;
	while(cin>>n>>k>>m&&n||m||k)
	{
		int x=1;
		int i,p;
		for(i=2;i<=n;i++)
		{
			if(i==n)
				p=k%i;
			else
				p=m%i;
			x=(x+p)%i;
			if(x==0)
				x=i;
		}
		cout<<x<<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