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

Alexander Kozlov
New poster
Posts: 23
Joined: Sun Jun 15, 2003 4:45 pm
Location: Ukraine

10521 - Continuously Growing Fractions

Post by Alexander Kozlov » Sun Jul 06, 2003 1:54 pm

Please, can sombody answer what should the correct output be
for inputs:

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


My program gives:

-5/7=0+1/{-1+1/{-2+1/{-2}}}
34/(-64)=0+1/{-1+1/{-1+1/{-7+1/{-2}}}}
9/(-5)=-1+1/{-1+1/{-4}}
-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}}

Is this output correct?

What about brackets [34/(-64) or 34/-64 or -34/64] when Q = -64 < 0?
What the output should be if Q == 0?

Dear authors, please, give us correct output format!

User avatar
Moni
Experienced poster
Posts: 202
Joined: Fri Mar 22, 2002 2:00 am
Location: Chittagong. CSE - CUET
Contact:

Re: 10521 ... Fractions - Please, specify output format!!!

Post by Moni » Sun Jul 06, 2003 2:23 pm

34/(-64)=0+1/{-1+1/{-1+1/{-7+1/{-2}}}}

What about brackets [34/(-64) or 34/-64 or -34/64] when Q = -64 < 0?


Don't use (-64) use just -64

i.e. 34/-64
ImageWe are all in a circular way, no advances, only moving and moving!

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per » Sun Jul 06, 2003 4:42 pm

Alexander: Apart from output formatting, there are actual errors in your output. For instance, floor(34/-64) != 0. (Read the problem statement very carefully)

Alexander Kozlov
New poster
Posts: 23
Joined: Sun Jun 15, 2003 4:45 pm
Location: Ukraine

Post by Alexander Kozlov » Sun Jul 06, 2003 6:31 pm

Dear Moni and Per!

Thank you very much! I got AC.

Red Scorpion
Experienced poster
Posts: 192
Joined: Sat Nov 30, 2002 5:14 am

Post by Red Scorpion » Fri Jul 11, 2003 9:18 am

What's The limit for P ? and Q ?

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Fri Jul 11, 2003 9:20 am

1000 or 2000 digits, I don't remember correct ...

DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

User avatar
Moni
Experienced poster
Posts: 202
Joined: Fri Mar 22, 2002 2:00 am
Location: Chittagong. CSE - CUET
Contact:

Post by Moni » Sat Jul 12, 2003 5:39 pm

Yeap! That was at most 2000 digits :)
ImageWe are all in a circular way, no advances, only moving and moving!

windows2k
Experienced poster
Posts: 136
Joined: Sat Apr 05, 2003 3:29 pm
Location: Taiwan

Post by windows2k » Mon Jul 14, 2003 10:50 am

Alexander Kozlov wrote:Dear Moni and Per!

Thank you very much! I got AC.
Ok, can you give the right output for your input above
Thx

Alexander Kozlov
New poster
Posts: 23
Joined: Sun Jun 15, 2003 4:45 pm
Location: Ukraine

Post by Alexander Kozlov » Mon Jul 14, 2003 2:22 pm

Input :

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


Output:

-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}}

Cosmin.ro
Learning poster
Posts: 95
Joined: Thu Aug 21, 2003 12:02 am

Post by Cosmin.ro » Thu Aug 21, 2003 12:12 am

My program works on the tests posted on the webboard, but I still get wa. What is the good output for +5 +6 and 1 1, on the webboard ac results don't have spaces near = but in the problem text the examples have spaces, what is the good way? Is there any tricky input? Also I haven't seen Pascal users having solved this task. Is there any problem with using pascal?

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per » Thu Aug 21, 2003 12:23 am

My AC solution does not handle '+' characters, but for input

Code: Select all

5 6
1 1
output is

Code: Select all

5/6 = 0+1/{1+1/{5}}
1/1 = 1
And you should put spaces around the '='.

Cosmin.ro
Learning poster
Posts: 95
Joined: Thu Aug 21, 2003 12:02 am

Post by Cosmin.ro » Thu Aug 21, 2003 1:20 am

how do you test for end of line and end of file?

Cosmin.ro
Learning poster
Posts: 95
Joined: Thu Aug 21, 2003 12:02 am

Post by Cosmin.ro » Fri Aug 22, 2003 4:27 pm

I got ac after rejudgement, thanks.

User avatar
babor
New poster
Posts: 16
Joined: Sat Jun 07, 2003 4:23 pm
Contact:

10521

Post by babor » Mon Sep 15, 2003 11:01 am

Hai I am getting wa

can anyone help me. Here is my code.

/*

/* @JUDGE_ID: XXXXXX 10521 C++ */
#include <stdio.h>

void main()
{
unsigned long long numar,denomi,temp;
long i,counter;

while(scanf("%llu %llu",&numar,&denomi)==2)
{

printf("%llu/%llu = %llu",numar,denomi,numar/denomi);
counter = 0;
temp = numar;
numar = denomi;
denomi = temp%denomi;
while(1 && denomi)
{

if(numar%denomi == 0)
{
printf("+1/{");
printf("%llu",numar/denomi);
counter++;
break;
}

printf("+1/{");
printf("%llu",numar/denomi);
temp = numar;
numar = denomi;
denomi = temp%denomi;
counter++;
}

for(i=0;i<counter;i++)
printf("}");
printf("\n");

}

}
/*@END_OF_SOURCE_CODE*/
*/

what is the reason . Have I missed something??????[/b]
babor

User avatar
cytmike
Learning poster
Posts: 95
Joined: Mon Apr 26, 2004 1:23 pm
Location: Hong Kong and United States
Contact:

Post by cytmike » Mon Jul 19, 2004 7:15 am

There may be at most 2000 digits in both P and Q.
Impossible is Nothing.

Post Reply

Return to “Volume 105 (10500-10599)”