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 |
扩展的欧几里德,In Reply To:我用相对运动去做! 但是超时!!!现附上我的程序!! 请各位高手指点下可以怎样修改!!先谢了!! Posted by:flyman at 2005-08-25 22:16:34 > #include<stdio.h> > #include<math.h> > void main() > { > int i; > long x,y,m,n,l; > long v,sum,temp; > scanf("%d%d%d%d%d",&x,&y,&m,&n,&l); > if(m==n) printf("Impossible\n"); > else > { > if(m>n) > { > v=m-n; > temp=x; > x=y; > y=temp; > } //y追x;x相对y静止 > else v=n-m; > sum=y; > i=0; > while(1) > { > sum+=v; > i++; > if(sum%l==x) > { > printf("%d\n",i); > break; > } > else if(sum%l==y) > { > printf("Impossible\n"); > break; > } > } > } > } > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator