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 Kudo at 2006-04-29 08:15:44 on Problem 1061
很久没编了~哎~
哪位大侠帮忙看看~那个边值问题没考虑到而导致这里不通过的。

自己的源程序:
#include<stdio.h>
main()
{
	long x, y, m, n, l, dist, k, t;
	int flag;

	do
	{
		scanf("%ld %ld %ld %ld %ld", &x, &y, &m, &n, &l);
	}
	while( x == y );                  // 这里是以防输入x = y的语句,要求重新输入。
    
	if( m > n )
		flag = 1;
	else if( m == n )
		flag = 0;
	else
		flag = -1;                    // 设置标志。

	switch( flag )
	{
	case 0: 
		printf( "Impossible\n" );
	
	case 1:
		if( x > y )
			dist = l - ( x - y );
		else
			dist = y - x; 

		for( k = 0; k < ( m - n ); k++ )
		{
			if( ( dist + k * l ) % ( m - n ) == 0 )
			{
				t = ( dist + k * l ) / ( m - n );
				printf( "%ld\n", t );
				break;
			}
			if( k == ( m - n - 1 ) )
				printf( "Impossible\n" );
		}

	case -1:
		if( x > y )
			dist = x - y;
		else
			dist = l - ( y - x );

		for( k = 0; k < ( n - m ); k++ )
		{
			if( ( dist + k * l ) % ( n - m ) == 0 )
			{
				t = ( dist + k * l ) / ( n - m );
				printf( "%ld\n", t );
				break;
			}
			if( k == ( m - n - 1 ) )
				printf( "Impossible\n" );
		}
	}
	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