Page 4 of 5

### Re: 11428 - Cubes

Posted: Sat Nov 09, 2013 6:19 am
Hi brianfry, for 631 my output is 15 14

### Re: 11428-I am tired getting WA again& again

Posted: Sat Nov 09, 2013 6:23 am
Sorry

### Re: 11428 - Cubes

Posted: Tue Nov 12, 2013 12:25 am
Your code has precision errors. When N = 631 and i = 14, on my system c = 14 and t = 0. The cuberoot of 3375 is exactly 15. Casting a double to an int is dangerous without adding a small value like 1e-8.

### Re: 11428 - Cubes

Posted: Tue Nov 12, 2013 7:30 pm
i add 0.0003 with the double value. but i am still getting WA. i have also tried with float. i tested my code for all the values from 1 t0 10000.plz,brianfry..tell me if the algorithm is ok! if its not then why?! and how can i improve this?
after adding 0.003 here is my new code-
plz help me

[removed]

### Re: 11428 - Cubes

Posted: Wed Nov 13, 2013 12:26 am
Your code is AC in C++. In C, it's always printing No solution. You could also try solving it without using floating point.

### Re: 11428 - Cubes

Posted: Wed Nov 13, 2013 8:50 am
thanx brianfry ..thanx a lot.is the cuberoot the cause?

### Re: 11428 - Cubes

Posted: Fri Nov 15, 2013 1:22 am
Yes, cbrt() is not part of ANSI C, it is returning 1.0 with any argument.

### 11428 - Cubes why WA?????

Posted: Wed Aug 27, 2014 11:54 am
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int a, b ,c, n;
long x;

while(cin>>n)
{
bool z=false;
if(n==0) break;
if(n==1)
{
cout<<"1 0\n";
continue;
}

for(a=1; a*a<n; a++)
{
x=a*a*a;

if(x==n)
{
cout<<a<<" 0\n";
z=true;
}

if(x>n)
{
for(b=1; b<a; b++)
{
long y=b*b*b;
if(x-y==n)
{
cout<<a<<" "<<b<<"\n";
z=true;
break;
}
}
}
}
if(z==false)
cout<<"No solution\n";
}
return 0;

}

### Re: 11428 - Cubes

Posted: Wed Aug 27, 2014 7:46 pm
Next time post in the existing thread. Input 1, AC output No solution

### Re: 11428 - Cubes

Posted: Wed Aug 27, 2014 8:21 pm
Each of these lines contains two positive integers x, y separated by a single space, such that

### Re: 11428 - Cubes

Posted: Wed Aug 27, 2014 8:34 pm
brianfry713 wrote:Next time post in the existing thread. Input 1, AC output No solution

Input 1, AC output No solution???
i dont understand :p

but i think for which case output could be 2 set or more this code printing all of them causing the ERROR.....

### Re: 11428 - Cubes

Posted: Wed Aug 27, 2014 9:33 pm
Input

Code: Select all

``````1
8
0``````
Acc output

Code: Select all

``````No solution
No solution``````

Code: Select all

``````1 0
2 0``````
Both x, y must be positive.

### Re: 11428 - Cubes

Posted: Mon Sep 01, 2014 9:45 pm
i am getting WA but i got accurate answer using http://www.udebug.com/UVa/11428 output:

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
int num;
int arr[100];
int a,b;
// freopen("text.txt","r",stdin);
while(scanf("%d",&num)==1)
{
if(num==0) break;
int flag=0;
if(num==1) printf("1 0\n");
else {
for(int i=0;i<=sqrt(num);i++)
{
arr=i;
}

for(int i=0;i<sqrt(num);i++)
{
for(int j=i+1;j<sqrt(num);j++)
{
if(((arr[j]*arr[j]*arr[j])-(arr*arr*arr))==num)
{
a=arr[j];
b=arr;
flag=1;
break;
}
}
}
if(flag==1) printf("%d %d\n",a,b);
else printf("No solution\n");
}

}
return 0;
}

### Re: 11428 - Cubes

Posted: Wed Sep 03, 2014 7:36 pm
Use code tags.
Input

Code: Select all

``````8
721
728
999
3367
5768
5824
7992
0
``````
Output

Code: Select all

``````No solution
9 2
9 1
10 1
15 2
18 4
18 2
20 2
``````
shaficse wrote:i am getting WA but i got accurate answer using http://www.udebug.com/UVa/11428 output:
According to problem description
Each of these lines contains two positive integers x, y separated by a single space, such that N = x^3 - y^3.
Maybe Judge doesn't have input when N = x^3.

It will be good if you remove all your codes after getting accepted.

### Re: 11428 - Cubes

Posted: Wed Sep 03, 2014 9:03 pm
try solving it without using floating point