Mark一下这种公约数求是否共线的情况,还有gcd,需要把之前的东西再写一遍了。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
int gcd ( int a , int b )
{
return b == 0 ? a:gcd ( b , a%b );
}
int l , sx , sy , px , py;
int main ( )
{
while ( ~scanf ( "%d" , &l ) )
{
if ( !l ) break;
scanf ( "%d%d%d%d" , &sx , &sy , &px , &py );
int dx = abs ( sx - px );
int dy = abs ( sy - py );
int d = gcd ( dx , dy );
if ( abs ( px ) > l || abs ( py ) > l )
{
puts ( "Out Of Range" );
continue;
}
if ( d == 1 )
puts ( "Yes" );
else puts ( "No" );
}
}