| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大家看看我这个算法,为什么老是提醒 超时?如何修改 谢谢了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator