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

这样都超时,我实在精简不了了

Posted by winter_1 at 2006-04-24 13:27:45 on Problem 1061
#include <stdio.h>
#include <math.h>
void main()
{
	int x,y,m,n,L;
	scanf("%d %d %d %d %d",&x,&y,&m,&n,&L);
	if(m==n){
		printf("Impossible\n");
	}
	else{
		if(m>n){
			for(int k=1;;k++){
				if(((m-n)*k-(y-x))%L==0){
					printf("%d\n",k);
					break;
				}
			}
		}
		else{
			for(int k=1;;k++){
				if(((n-m)*k+(y-x))%L==0){
					printf("%d\n",k);
					break;
				}
			}
		}
	}
}



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