## 10483 - The Sum Equals the Product

Moderator: Board moderators

erfan
New poster
Posts: 44
Joined: Tue Apr 15, 2003 4:31 pm
Contact:
Thanks little joy.
Your's first and last output is same as me and equation is also same.Can you say a=100;a<25600 and b=a+1;b<25600.it is correct

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
No, I would say: 1<=a; a*a*a<256000000 and a<=b; a*b*b<256000000.
a can be as small as one cent, b can be equal to a.

erfan
New poster
Posts: 44
Joined: Tue Apr 15, 2003 4:31 pm
Contact:
Thanks little joey at last i got AC it.

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am

### Re: 10483 - Why WA ???

Hi
I don't know why my code produces 352 triples. It also produced 352 triples after I changed my code as you said in previous posts. Please tell me which triples am i missing?
Here is my code:

Code: Select all

``````Thank you, Jan
``````
Last edited by hamedv on Wed Apr 23, 2008 3:51 pm, edited 1 time in total.

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

Code: Select all

``5.40 = 1.50 + 1.50 + 2.40 = 1.50 * 1.50 * 2.40``
Ami ekhono shopno dekhi...
HomePage

shakil
Learning poster
Posts: 74
Joined: Sat Jul 15, 2006 6:28 am
Contact:

### Re: 10483 - The Sum Equals the Product

Why WA!!! Please, some one check my outputs & say what is the problem in my triples. Thanks

Code: Select all

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

long P[1009],A[1009];
long sam1[1009],sam2[1009],sam3[1009],n,sam;

void make(long h1,long h2,long h3)
{

long long x1,x2,x3,x4,i,v1,v2;

x1 = h3 - h1;
x2 = (h3 * 10000)/h1;

x3 = x1*x1 - 4 * x2;

if(x3>0)
{
x4 = sqrt(x3);
if((x4+1)*(x4+1)==x3)
x4++;
if(x4*x4==x3)
{
v1 = (x1 + x4 )/2;
v2 = (x1 - x4)/2;
if(v1 + v2 + h1 == h3 && v1 * v2 * h1 == h3*10000)
{
// && sam1 > h1
if(h1>v1)
{
x1 = h1;
h1 = v1;
v1 = x1;
}

if(v1>v2)
{
x1 = v1;
v1 = v2;
v2 = x1;
}

if(h1>v1)
{
x1 = h1;
h1 = v1;
v1 = x1;
}

sam1[sam] = h1;
sam2[sam] = v1;
sam3[sam] = v2;
sam++;
}
}
}

for(i=h2;i<n;i++)
{
if(i==h2)
{
x1 = (h1*A[i]);
x1 *= (h1*A[i]);
x1 *= (h1*A[i]);
//h1*A[i]<sam1&&
if(x1<=h3*10000)
make(h1*A[i],i+1,h3);
}
else if(A[i]!=A[i-1])
{
x1 = (h1*A[i]);
x1 *= (h1*A[i]);
x1 *= (h1*A[i]);
//h1*A[i]<sam1&&
if(x1<=h3*10000)
make(h1*A[i],i+1,h3);
}
}
}

int main()
{

long i,j,N,nn,k3,k4,tt,count,v1,v2;
double k1,k2,b1,b2,b3,b4;

for(i=3;i<=sqrt(650);i=i+2)
if(P[i]==0)
for(j=i*i;j<=650;j=j+i+i)
P[j]=1;

P[0]=2;
N=1;

for(i=3;i<=650;i=i+2)
if(P[i]==0)
{
P[N]=i;
N++;
}

nn=0;
k3 = 10000;

for(i=0;i<N;i++)
{
if(P[i]>k3)
break;
while(k3%P[i]==0)
{
A[nn]=P[i];
nn++;
k3=k3/P[i];
}
}

while(scanf("%lf %lf",&k1,&k2)==2)
{
k3 = (k1*100 + 0.1);
k4 = (k2*100 + 0.1);

if(k3<500)
k3=500;

count = 0;
for(i=k3;i<=k4;i++)
{
n = nn;
tt = i;

for(j=0;j<N;j++)
{
if(P[j]>tt)
break;
while(tt%P[j]==0)
{
A[n]=P[j];
n++;
tt=tt/P[j];
}
}

sam = 0;
make(1,0,i);

if(sam!=0)
{
for(v1=0;v1<sam-1;v1++)
for(v2=0;v2<sam-1-v1;v2++)
if(sam1[v2]>sam1[v2+1])
{
sam1[sam]=sam1[v2];
sam1[v2]=sam1[v2+1];
sam1[v2+1]=sam1[sam];
sam2[sam]=sam2[v2];
sam2[v2]=sam2[v2+1];
sam2[v2+1]=sam2[sam];
sam3[sam]=sam3[v2];
sam3[v2]=sam3[v2+1];
sam3[v2+1]=sam3[sam];
}

for(v1=0;v1<sam;v1++)
if(v1==0||sam1[v1]!=sam1[v1-1])
{
b1 = i;
b2 = sam1[v1];
b3 = sam2[v1];
b4 = sam3[v1];
b1/=100;b2/=100;b3/=100;b4/=100;
printf("%.2lf = %.2lf + %.2lf + %.2lf = %.2lf * %.2lf * %.2lf\n",b1,b2,b3,b4,b2,b3,b4);
count++;
}
}
}
//printf("%ld\n",count);
}
return 0;
}

``````
SHAKIL

mak(cse_DU)
Learning poster
Posts: 72
Joined: Tue May 30, 2006 5:57 pm

### Re: 10483 - The Sum Equals the Product

Some one who are getting WA after counting 354 outputs in total.

Check start and end of your output.

Code: Select all

``````5.25 = 1.50 + 1.75 + 2.00 = 1.50 * 1.75 * 2.00  //1st output
5.40 = 1.50 + 1.50 + 2.40 = 1.50 * 1.50 * 2.40
5.46 = 1.40 + 1.56 + 2.50 = 1.40 * 1.56 * 2.50
5.49 = 1.25 + 1.80 + 2.44 = 1.25 * 1.80 * 2.44
5.55 = 1.20 + 1.85 + 2.50 = 1.20 * 1.85 * 2.50
5.61 = 1.36 + 1.50 + 2.75 = 1.36 * 1.50 * 2.75
.................................................................
.................................................................
245.07 = 0.02 + 70.00 + 175.05 = 0.02 * 70.00 * 175.05
253.17 = 0.04 + 28.13 + 225.00 = 0.04 * 28.13 * 225.00
253.26 = 0.96 + 1.05 + 251.25 = 0.96 * 1.05 * 251.25
254.52 = 0.50 + 2.02 + 252.00 = 0.50 * 2.02 * 252.00
254.52 = 0.90 + 1.12 + 252.50 = 0.90 * 1.12 * 252.50  // 354th output
``````
Hope it will help
Mak
Help me PLZ!!