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 jxnuxiaoyong at 2008-10-29 11:49:28 on Problem 1061
#include    "stdio.h"


void main()
{
    unsigned long int x,y,m,n,l;
    unsigned long int i=1,a,b;
    
    scanf("%ld %ld %ld %ld %ld",&x,&y,&m,&n,&l);
    a=(m+x)%l;
    b=(n+y)%l;
    while(((i*m+x)%l)!=((i*n+y)%l))
    {
        i++;
        if((((i*m+x)%l==a)&&((i*n+y)%l==b))||(i>l))
            {i=0;break;}
    }
    if(i==0)
        printf("Impossible\n");
    else
        printf("%ld\n",i);

    getch();
}

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