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:houxuanfelix at 2006-05-14 22:29:01 > #include <stdio.h> > int main() > { > int x,y,m,n,l; > while (scanf ("%d%d%d%d%d",&x,&y,&m,&n,&l)!=EOF) > { > if (m>n) > { > m=m-n; > x=(y-x+l)%l; > } > else > { > m=n-m; > x=(x-y+l)%l; > } > n=x/m; > x=x%m; > y=x; > while (1) > { > if (y==0) > { > printf ("%d\n",n); > break; > } > n+=(y+l)/m; > y=(y+l)%m; > if (y==x) > { > printf ("Impossible\n"); > break; > } > } > } > return 0; > } > //我实在想不出它为什么会超时,这时间复杂度根本就不高啊??????????????????????????????搞不懂啊!! > 大牛救命!! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator