## 11428 - Cubes

Moderator: Board moderators

### Re: 11428 - Cubes

I got so many WA.
Code: Select all
`removed`
Last edited by Obaida on Wed Jan 07, 2009 7:36 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper

Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11428 - Cubes

Read the description please. 'If there is more than one solution then output the one with smallest value of y.'
I think you are maximizing y.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru

Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm

### Re: 11428 - Cubes

Oh....
tomorrow i was kidding with my self.
Thank for fixing mistake.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper

Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11428 - Cubes

What's the prb in this code!!!!!!!!!!! its freaking me off

Code: Select all
`#include<stdio.h>#include<string.h>int main(){//   freopen("input.txt","r",stdin);//   freopen("output.txt","w",stdout);   long int i,j,y,N;   int digits[10005][2];   for(i=1;i<100;i++)      {         for(j=1;j<i;j++)         {            y=i*i*i-j*j*j;            if(y<=10000 && digits[y][0]<0)            {               digits[y][0]=i;               digits[y][1]=j;            }         }      }   while(scanf("%ld",&N))   {            if(N==0)break;      if(digits[N][0]>0)         printf("%d %d\n",digits[N][0],digits[N][1]);      else         printf("No solution\n");   }   return 0;}`
shafin.MIST
New poster

Posts: 1
Joined: Fri Oct 22, 2010 3:54 pm

### Re: 11428 - Cubes

[code][/code]

#include<stdio.h>
#include<math.h>

int main()
{
int flag , j , k , k1 ;
int i , temp , temp1 ;
int a[50] , b[50] ;

for(j=0 ; j<50 ; j++)
a[j] = pow(j , 3) ;

while( scanf("%d" , &i ) == 1 )
{
if( i == 0 )
break ;

for(j=0 ; j<50 ; j++)
b[j] = 0 ;

k=0 ;
for(j=0 ; j<50 ; j++)
{
if( a[j] <= i )
b[k++] = a[j] + i ;
else if( i > a[j] )
break ;
}

flag=0 ;
k=0 ;
for(j=0 ; j<50 ; j++)
{
for(k1=0 ; k1<50 ; k1++)
{
if( b[k1] == a[j] )
{
temp = j ;
flag = 1 ;
break ;
}
}
}

temp1 = a[temp] - i ;

for(j=0 ; j<50 ; j++)
{
if( a[j] == temp1 )
{
temp1 = j ;
break ;
}
}

if( flag == 1 && temp > temp1 && temp1 >= 0 )
printf("%d %d\n" , temp , temp1 ) ;
else
printf("No solution\n") ;
}
return 0 ;
}
[quote][/quote] can anyone give me speial test case???find any bug???
santosh
New poster

Posts: 2
Joined: Thu Apr 14, 2011 2:57 pm

### Re: 11428 - Cubes

Thanx for the codes!!cell phone tracking it's highly appreciated I’ve manipulated the code and I’m using it to help others. I hope that is fine ;D
Gabrielwer
New poster

Posts: 6
Joined: Thu Sep 08, 2011 12:27 pm

### Re: 11428 - Cubes

Here is my code...

#include<stdio.h>
int main()
{
int n,x,y,i,j,flag,m;
while(scanf("%d",&n)==1)
{
if(n==0) break;
x=0;
y=0;
flag=0;
for(j=0;j<=22;j++)
{
for(i=1;i<=28;i++)
{
if(i<j) continue;
m=(i*i*i)-(j*j*j);
if(m==n)
{
x=i;
y=j;
flag=1;
break;
}
}
if(flag==1) break;
}
if(x==0&&y==0)
printf("No solution\n");
else
printf("%d %d\n",x,y);
}
return 0;
}
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
alimbubt
New poster

Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm

### Re: 11428 - Cubes

40*40*40-39*39*39=4681
brianfry713
Guru

Posts: 1754
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11428 - Cubes

brianfry713 wrote:40*40*40-39*39*39=4681

Thanks
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
alimbubt
New poster

Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm

### Re: 11428 - Cubes

why wrong ans

Code: Select all
`#include<stdio.h>#include<math.h>int main(){    double f,t;    int i,c,n;    int flag=0;    while(scanf("%d", &n)==1) {        if(n==0)        break;    for(i=1; ; i++) {zz:if(flag == 1){i=i+1;flag=0; }    f = n + (i*i*i);    t = cbrt(f);    c = t;    if(i>=t)    break;    if(c == t)    {flag = 1;    break;}  }    if(n!=((c*c*c)-(i*i*i)) && flag == 1)    goto zz;    if(flag == 1)    { printf("%d %d\n", c,i);    flag = 0; }    else    printf("No solution\n");}return 0;}`
mahbub2012
New poster

Posts: 5
Joined: Fri Nov 09, 2012 11:33 pm

### Re: 11428 - Cubes

That doesn't match the sample I/O.
brianfry713
Guru

Posts: 1754
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11428 - Cubes

i've got wa many times.but i check the sample test cases here .can anyone help?
#include <stdio.h>

int main ()
{
scanf ("%lld",&n);
while (n!=0){
j=1;
flag=0;
while (1){
for (i=0;i<j;i++){
x2=j*j;
y2=i*i;
x2y2=x2+y2;
if (x2y2>n){
break;
}
x2y2+=(i*j);
x2y2*=(j-i);
if (x2y2==n){
printf ("%lld %lld\n",j,i);
flag=1;
}
}
break;
j++;
}
if (flag==0)
printf ("No solution\n");

scanf ("%lld",&n);
}
return 0;
}
Last edited by shuvrothpol1 on Thu Jan 24, 2013 8:25 am, edited 1 time in total.
shuvrothpol1
New poster

Posts: 17
Joined: Wed Aug 15, 2012 12:37 pm

### Re: 11428 - Cubes

Try input:
Code: Select all
`7210`
AC output:
Code: Select all
`9 2`
brianfry713
Guru

Posts: 1754
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11428 - Cubes

tnx acceptep..
shuvrothpol1
New poster

Posts: 17
Joined: Wed Aug 15, 2012 12:37 pm

Previous