10521 - Continuously Growing Fractions

All about problems in Volume 105. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Eduard
Experienced poster
Posts: 183
Joined: Fri Sep 26, 2003 2:54 pm
Location: Armenia,Yerevan

10521

Post by Eduard »

Hello.
I'm getting TLE forr this problem can't understand why.I think there is some special cases.Because I solve problem 834 and my program is giving right answers for this kind of tests.
Input

Code: Select all

-5 7 
34 -64 
9 -5 
-33 -57 
123456789123456789 987654321 
55555555555555555555 66666666666666666666 
Output

Code: Select all

-5/7=-1+1/{3+1/{2}} 
34/-64=-1+1/{2+1/{7+1/{2}}} 
9/-5=-2+1/{5} 
-33/-57=0+1/{1+1/{1+1/{2+1/{1+1/{2}}}}} 
123456789123456789/987654321=124999998+1/{1+1/{70+1/{9+1/{2170+1/{2+1/{1+1/{2+1/{1+1/{1+1/{1+1/{2}}}}}}}}}}} 
55555555555555555555/66666666666666666666=0+1/{1+1/{5}}
If somebody can help please tell me what can be reason of TLE.
Thanks.
someone who like to solve informatic problems.
http://acm.uva.es/cgi-bin/OnlineJudge?AuthorInfo:29650
lovemagic
Learning poster
Posts: 52
Joined: Thu Oct 02, 2003 11:38 am

10521 Why WA?

Post by lovemagic »

i think Q!=0,is it?
Is input terminated by EOF?
Here's some test cases.Where's the wrong?

-0 10
0 -10
-00 -100
-5 -5
-5 5
5 5
5 -5
-0000001 1
10 -01
123465417841234654 324324535293485945680579670
1111111 23243546534965867569756
348256345439658746 234234324
-12323214 2131234857943657
63214612 -0000213217362137658876876

my WA code gives----

0/10 = 0
0/-10 = 0
0/-100 = 0
-5/-5 = 1
-5/5 = -1
5/5 = 1
5/-5 = -1
-1/1 = -1
10/-1 = -10
123465417841234654/324324535293485945680579670 = 0+1/{2626845160+1/{12+1/{1+1/{1+1/{11+1/{1+1/{2+1/{6+1/{8+1/{2+1/{1+1/{3+1/{1+1/{1+1/{6+1/{1+1/{5+1/{6+1/{3+1/{1+1/{94+1/{1+1/{4+1/{2+1/{1+1/{1+1/{2+1/{1+1/{1+1/{3+1/{4+1/{2+1/{1+1/{1+1/{1+1/{20}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
1111111/23243546534965867569756 = 0+1/{20919193973388678+1/{6+1/{1+1/{1+1/{2+1/{6+1/{1+1/{1+1/{34+1/{1+1/{5+1/{1+1/{9}}}}}}}}}}}}}
348256345439658746/234234324 = 1486786135+1/{1+1/{2+1/{1+1/{45+1/{1+1/{3+1/{4+1/{4+1/{17+1/{1+1/{1+1/{1+1/{1+1/{5+1/{1+1/{14}}}}}}}}}}}}}}}}
-12323214/2131234857943657 = -1+1/{1+1/{172944724+1/{7+1/{1+1/{2+1/{2+1/{78+1/{1+1/{4+1/{2+1/{1+1/{10+1/{1+1/{1+1/{3+1/{2}}}}}}}}}}}}}}}}
63214612/-213217362137658876876 = -1+1/{1+1/{3372912612950+1/{1+1/{6+1/{1+1/{12+1/{7+1/{2+1/{2+1/{2+1/{3+1/{1+1/{1+1/{2+1/{3+1/{3+1/{3+1/{2}}}}}}}}}}}}}}}}}}

Are there any critical test case?
khobaib
Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko »

This problem helped me find a bug in my BigInt:

Input (should be one line, maybe it's wrapped):

Code: Select all

00000000000000000123456789123456789123456789123456789 -123456789123456789123456789123456789123456789
Output (same thing, should be one line):

Code: Select all

123456789123456789123456789123456789/-123456789123456789123456789123456789123456789 = -1+1/{1+1/{999999999+1/{1000000001000000001000000001}}}

Post Reply

Return to “Volume 105 (10500-10599)”