|
|
back to boardWhy I get wa on 31# Posted by lql1993 28 Feb 2009 17:36 I think my program works well,but I get wa on 31#,could you help me? Re: Why I get wa on 31# my algorithm is that: if a conect to b,and b conect to c,so a%n==c%n; that means c=a+n;and the first cycle will happen at max(b+n,a+n); if a conect to a+n, ans the first cycle will happen at a+2*n; so there is no way to output -1, Am i right? I can't even past the 3th testcase. Re: Why I get wa on 31# I had WA 31 too. You have to check where you use square of variables to except overflow. Edited by author 01.03.2009 20:02 Re: Why I get wa on 31# Thanks,And I have got accept now. I get wrong answer because I used longint while I use square of variables. I have an O(n) algrithm,but I wonder if there is a math algrithm. Edited by author 02.03.2009 15:11 |
|
|