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 melis at 2005-12-02 11:45:08 on Problem 1061
#include <iostream>
using namespace std;
int  main()
{
    long x,y,m,n,l;
    do cin >> x >> y>>m>>n>>l;
    while (
!(x!=y&&x<2000000000&&y<2000000000&&m>0         //验证输入数据合法性
&&m<2000000000&&n>0&&n<2000000000 
&&l>0&&l<2100000000)  
    );


x=(x+l)%l;     //x,y坐标变成正直
y=(y+l)%l;

if(m==n) { cout<<"impossible"<<endl; 
           return 0;
         }
   

 
 
 
  long  i=y+n-m,num=1;
  while(  ((i+l)%l)!=x&& ((i+l)%l)!=y)       //如果有重复点或者追到a就退出
  { i=(i+n-m)%l;
    num++;
   }


 if(((i+l)%l)==y)  cout<<"impossible";//重复点
 else  cout<<num<<endl;
 
return 1;
     
}

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