138 - Street Numbers

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

Moderator: Board moderators

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Thanks!.

Post by _.B._ » Tue Apr 06, 2004 5:10 am

Greetings.
Thanks!, I will.
_.

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Wed Apr 21, 2004 10:40 am

You could lookup "Pell's equation" at mathworld.wolfram.com.

One can solve this equation using continued fractions (square root of 2 in this case).

Using this solution I got an even better timing than just printing the pre-calculated results!

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Good maths.

Post by _.B._ » Wed Apr 21, 2004 9:51 pm

Thanks!.
Will take a look to it :wink:
Keep posting!.
_.

sunmoon
New poster
Posts: 4
Joined: Tue Jun 29, 2004 12:50 pm
Contact:

Try using this relation

Post by sunmoon » Tue Jun 29, 2004 1:13 pm

Consider the equations,
y^2 - 2x^2=1 ; 2y^2-x^2=1

If (a,b) is a solution to one of the above equations,
then (3a+4b,2a+3b) is also a solution.

Hope you get it!!
All

ravi,IITM.

Erik
Learning poster
Posts: 67
Joined: Fri Jul 01, 2005 11:29 am
Location: Germany
Contact:

138: WA

Post by Erik » Tue Aug 29, 2006 4:29 pm

Hi,

I got the solution for problem 138 and I'm sure it is right.
That's as all outputs obey the desired property and they correspond with the outputs given on other threads.

Could anyone who solved this problem please check my solution? I could send it as private message.

Cu, Erik :)

Erik
Learning poster
Posts: 67
Joined: Fri Jul 01, 2005 11:29 am
Location: Germany
Contact:

Post by Erik » Thu Aug 31, 2006 5:48 pm

:oops:
After many hours of testing I finally realized that I messed up the I/O.
On my machine I work with files for acm and hence use conditional compilation. I messed that up so it worked for me but not the judge.
:oops:

andysoft
Experienced poster
Posts: 109
Joined: Sat Jun 23, 2007 9:53 pm
Location: Brest, BELARUS
Contact:

Post by andysoft » Wed Aug 08, 2007 4:41 pm

Hi people!
I have a question.
I am submitting my prog for many times, but judge still says "WA". My output is the following (except spaces added by 'code' tag in the end of line):

Code: Select all

         6         8
        35        49
       204       288
      1189      1681
      6930      9800
     40391     57121
    235416    332928
   1372105   1940449
   7997214  11309768
  46611179  65918161
I am sure this is correct, but how do I get WA??
Thanx in advance!!
Now I lay me down to sleep...
my profile

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Wed Aug 08, 2007 5:52 pm

Your outputs are correct. Remove them. Submit again.
Ami ekhono shopno dekhi...
HomePage

apurba
New poster
Posts: 42
Joined: Sun Oct 07, 2007 10:29 pm

problem no 138--help pls

Post by apurba » Sat Dec 29, 2007 5:39 pm

why getting wa?
someone pls check that out.
here is my code.......

Code: Select all




help pls.
i saw other thread but they are not helpful enough to get my answer.
thanks in advance.
Last edited by apurba on Sun Dec 30, 2007 7:03 pm, edited 1 time in total.

Code: Select all

keep dreaming...

ovidiu
New poster
Posts: 10
Joined: Fri Dec 07, 2007 10:42 am

Post by ovidiu » Sat Dec 29, 2007 7:46 pm

Your code displays many times the same pair, like:

Code: Select all

         6          8
         6          8
         6          8
         6          8
         6          8
...

apurba
New poster
Posts: 42
Joined: Sun Oct 07, 2007 10:29 pm

Post by apurba » Sun Dec 30, 2007 6:54 am

ovidiu wrote:Your code displays many times the same pair, like:

Code: Select all

         6          8
         6          8
         6          8
         6          8
         6          8
...
i have noticed that my code gives 3 correct output but repeat them.
why this is happening?

Code: Select all

keep dreaming...

ovidiu
New poster
Posts: 10
Joined: Fri Dec 07, 2007 10:42 am

Post by ovidiu » Sun Dec 30, 2007 11:42 am

Because you have the lines:

Code: Select all

long count=0; 
if(count==10)
count will always be 0 in this if ...

It seems it is important that you learn to debug the code.
Set a breakpoint at line:
count++;
and watch the variable i.

apurba
New poster
Posts: 42
Joined: Sun Oct 07, 2007 10:29 pm

fed up with the problem

Post by apurba » Sun Dec 30, 2007 7:00 pm

ovidiu wrote:Because you have the lines:

Code: Select all

long count=0; 
if(count==10)
count will always be 0 in this if ...
it works.
but now i am getting only 5 outputs.
and it is working too slow.
thanks for ur help..........
here is my updated code.........

Code: Select all


i m really fed up with this problem!!!!!!!!!!!!!!!!!!!
Last edited by apurba on Mon Dec 31, 2007 7:21 am, edited 1 time in total.

Code: Select all

keep dreaming...

ovidiu
New poster
Posts: 10
Joined: Fri Dec 07, 2007 10:42 am

Post by ovidiu » Mon Dec 31, 2007 7:02 am

Think if you really need to compare temp1 with n.

WAandAC
New poster
Posts: 4
Joined: Sat Nov 03, 2007 4:32 am

Re: problem no 138--help pls

Post by WAandAC » Sun Jun 29, 2008 2:43 am

Hi,

I think this is an easy problem, but why i get wa?

Here is my code

Code: Select all

#include <iostream>
using namespace std;
int main ()
{
	int l1 [10] = {6, 35, 204, 1189, 6930, 256, 7742, 11707, 19813, 25162};
	int l2 [10] = {8 ,49, 288, 1681, 9800, 131072, 131528, 132113, 134033, 135816};
	for ( int i = 0; i < 10; i++)
	{
		printf ("%10d%10d\n", l1[i], l2[i]);
	}
	return 0;
}
Here is my output

Code: Select all

         6         8
        35        49
       204       288
      1189      1681
      6930      9800
       256    131072
      7742    131528
     11707    132113
     19813    134033
     25162    135816
Can anyone help me? Thank you!

Post Reply

Return to “Volume 1 (100-199)”