ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1682. Crazy Professor

Why 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#
Posted by crackerwang 1 Mar 2009 07:29
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#
Posted by Programmer 1 Mar 2009 18:37
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#
Posted by lql1993 2 Mar 2009 15:06
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