Code: Select all

`216 125`

Code: Select all

`127 623`

Check it yourself with the code you have posted.

**Moderator:** Board moderators

Code: Select all

`216 125`

Code: Select all

`127 623`

Check it yourself with the code you have posted.

Code: Select all

`if((unsigned long) pow(n,(double)1/d)+1 == (unsigned long) pow(h,(double)1/d))`

I wonder how you got correct answer in your computer with this mistake!

I got the correct answer for this case, too. It may be computer dependent.mamun wrote:Check this lineCan you find the mistake now?Code: Select all

`if((unsigned long) pow(n,(double)1/d)+1 == (unsigned long) pow(h,(double)1/d))`

I wonder how you got correct answer in your computer with this mistake!

Sample INPUT

1 1

16 9

65536 6561

216 125

5764801 1679616

0 0

Sample OUTPUT

0 1

4 37

3280 242461

31 671

335923 30275911

1 1

16 9

65536 6561

216 125

5764801 1679616

0 0

Sample OUTPUT

0 1

4 37

3280 242461

31 671

335923 30275911

Hi,

i have WA and need some test data to debug my code (it's hard to make a test for this problem, yeah?).

Anyway i'm posting my code too, maybe someone would want to debug it himself.

Thanks in advance,

Narek Saribekyan

i have WA and need some test data to debug my code (it's hard to make a test for this problem, yeah?).

Anyway i'm posting my code too, maybe someone would want to debug it himself.

Code: Select all

```
#include <stdio.h>
#include <math.h>
void main() {
int x, y, h, n, r, s ;
double c, l;
while ( scanf ("%d%d", &x, &y ) ) {
if (x==0 && y==0) break ;
c = log ( (double)x )/log ( (double)y ) ;
for ( n=1; n<=y; n++ )
if ( fabs( pow( (double)n,c )-(double)n-1.0 ) < 0.001 ) break ;
h = (int)(log ( (double)y )/log ( (double)n )) ;
r = (int)(pow ( (double)n,(double)h+1 )-1)/(n-1) - y;
l = n/(double)(1+n);
s = (int) ( x*( pow ( l,(double)(h+1) )-1 )/(double)(l-1) + 0.001);
printf ( "%d %d\n", r, s );
}
}
```

Narek Saribekyan

Narek Saribekyan

- emotional blind
- A great helper
**Posts:**383**Joined:**Mon Oct 18, 2004 8:25 am**Location:**Bangladesh-
**Contact:**

I give u some input and output of my accepted code.

INPUT
OUTPUT
Your program produce different output..

Do you need any more help?

INPUT

Code: Select all

```
100 1
1000 1
10000 1
0 0
```

Code: Select all

```
7 199
10 1999
13 19999
```

Do you need any more help?

no, i think i found my bug. the problem is the second number - 1, i have division by zero.

got it!!!

btw. your input was wrong - it is not possible to build a tree with that parameters, anyway, you helped me to find my mistake, thanks very much !!!

got it!!!

btw. your input was wrong - it is not possible to build a tree with that parameters, anyway, you helped me to find my mistake, thanks very much !!!

Last edited by snar on Thu May 04, 2006 3:52 pm, edited 1 time in total.

Narek Saribekyan

test data doesn't have this case!

Code: Select all

```
100 1
1000 1
10000 1
```