11428 - Cubes

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

Moderator: Board moderators

Re: 11428 - Cubes

Postby Obaida » Tue Jan 06, 2009 11:29 am

I don't know what's going on with me. Some one please help me to get ACC.
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
Location: (BUBT) Dhaka,Bagladesh.

Re: 11428 - Cubes

Postby Jan » Tue Jan 06, 2009 3:45 pm

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
Location: Dhaka, Bangladesh

Re: 11428 - Cubes

Postby Obaida » Wed Jan 07, 2009 7:36 am

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
Location: (BUBT) Dhaka,Bagladesh.

Re: 11428 - Cubes

Postby shafin.MIST » Fri Oct 22, 2010 3:59 pm

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

Postby santosh » Thu Apr 14, 2011 3:07 pm

[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

Postby Gabrielwer » Fri Sep 09, 2011 3:26 pm

Thanx for the codes!!cell phone tracking it's highly appreciated :DI’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

Postby alimbubt » Mon Oct 22, 2012 6:32 pm

I am getting continuously wrong answer..Please help me......
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
Location: BUBT,Dhaka, Bangladesh

Re: 11428 - Cubes

Postby brianfry713 » Tue Oct 23, 2012 10:56 pm

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

Postby alimbubt » Mon Oct 29, 2012 9:42 pm

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

Thanks :D :D
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
Location: BUBT,Dhaka, Bangladesh

Re: 11428 - Cubes

Postby mahbub2012 » Tue Nov 13, 2012 11:24 pm

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

Postby brianfry713 » Wed Nov 14, 2012 1:43 am

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

Postby shuvrothpol1 » Wed Jan 23, 2013 10:51 pm

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

int main ()
{
long long int n,i,x2,y2,x2y2,flag,alert,j;
scanf ("%lld",&n);
while (n!=0){
j=1;
flag=0;
alert=0;
while (1){
for (i=0;i<j;i++){
x2=j*j;
y2=i*i;
x2y2=x2+y2;
if (x2y2>n){
alert=1;
break;
}
x2y2+=(i*j);
x2y2*=(j-i);
if (x2y2==n){
printf ("%lld %lld\n",j,i);
flag=1;
}
}
if (alert==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

Postby brianfry713 » Thu Jan 24, 2013 2:36 am

Try input:
Code: Select all
721
0
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

Postby shuvrothpol1 » Thu Jan 24, 2013 8:24 am

tnx acceptep..
shuvrothpol1
New poster
 
Posts: 17
Joined: Wed Aug 15, 2012 12:37 pm

Previous

Return to Volume CXIV

Who is online

Users browsing this forum: No registered users and 0 guests