## 10209 - Is This Integration ?

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

Moderator: Board moderators

ferir
New poster
Posts: 1
Joined: Sat Dec 08, 2001 2:00 am

### 10209 - Is This Integration ?

is the example input right
in my view:
0.1
0.2
0.3
output should be :
0.003 0.005 0.002
0.012 0.019 0.009
0.027 0.043 0.020

yatsen
Learning poster
Posts: 68
Joined: Fri Nov 23, 2001 2:00 am
Location: taiwan
I got WA for this problem:10209.
I think my math logic is right.
But I made some mistake in dealing with the digits. Could anyone tell me what is the value of PI? I don't think 3.14159 is good enough for this problem. Thank you!

Yeamin Rajeev
New poster
Posts: 7
Joined: Wed Dec 12, 2001 2:00 am
You may try PI = 2.0*acos(0.0);

yatsen
Learning poster
Posts: 68
Joined: Fri Nov 23, 2001 2:00 am
Location: taiwan
I got ACCEPTED. Thanx!

Rossi
New poster
Posts: 20
Joined: Thu Mar 21, 2002 2:00 am
i calculated the constants by pure math.whats wrong with it.thanks

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

void main(void)
{
register int i;
double a,x,y,z,temp,pi_3,sqrt3,cx,cy,cz;

pi_3=2.0*acos(0.0)/3.0;
sqrt3=sqrt(3.0);
cx=(4.0-sqrt3-(2.0*pi_3));
cy=(pi_3+(2.0*sqrt3)-4.0);
cz=(pi_3+1.0-sqrt3);

while(1){
if(scanf("%lf",&a)!=1)
break;

x=a*a*cx;
y=a*a*cy;
z=a*a*cz;

printf("%.3lf %.3lf %.3lfn",z,y,x);
}
}

Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:
Check your mail program. I just got your program accepted without changes.

Rossi
New poster
Posts: 20
Joined: Thu Mar 21, 2002 2:00 am
Thankx

AlexandreN
New poster
Posts: 27
Joined: Sun Jul 07, 2002 6:46 pm
Location: Campina Grande - Brazil
Contact:
look at the printf. where is the \n ?

haaaz
New poster
Posts: 29
Joined: Sun Sep 08, 2002 8:02 am
This must work:

#include <iostream.h>
#include <iomanip.h>

int main5() {

double a;
cout.setf(ios::fixed);
cout.precision(3);

while(cin>>a) {

cout << a*a*0.3151467436277204526267681195873 << ' '
<< a*a*0.51129916633435233320910714410491 << ' '
<< a*a*0.17355409003792721416412473630779 << endl;

}
return 0;
}

hts
New poster
Posts: 8
Joined: Sat Feb 22, 2003 2:56 am

### 10209: Is this integration? WA!!@@#!

http://acm.uva.es/p/v102/10209.html

I derived the area of the regions the problem asked, then I implemented it on my solution.
It worked well with all tests cases, by I only got WA :/

Can anyone help-me on this?

Code: Select all

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

#define PI 3.1415926535897932384626433832795
#define	SQUARE_3	1.73205080756887729352744634150587

int	main(){
float	a;

while(scanf("%f", &a) == 1)
{
a = a*a;

printf("%.3f %.3f %.3f\n",
0.315147*a, /* (1+PI/3-SQUARE_3)*a, */
0.511299*a, /* 4*(-1+PI/12+SQUARE_3/2)*a, */
0.173554*a  /* 4*(1-PI/6-SQUARE_3/4)*a */
);
}
}
``````

yahoo
Learning poster
Posts: 93
Joined: Tue Apr 23, 2002 9:55 am
Try to use PI as 2*acos(0).
Hope it can help.

shahriar_manzoor
System administrator & Problemsetter
Posts: 399
Joined: Sat Jan 12, 2002 2:00 am
I have not ckecked your solution but I guess float is not enough for this problem. Use double.

hts
New poster
Posts: 8
Joined: Sat Feb 22, 2003 2:56 am
Implemented pi = 2*acos(0) and double... but W.A. again

binkid
New poster
Posts: 1
Joined: Fri Oct 24, 2003 1:23 am
Contact:

### use higher precision

Neither float nor double, the problem is the precision of the constant that your're using to multiply a

newcrama
New poster
Posts: 1
Joined: Wed Jul 07, 2004 10:11 am

### 10209 T_T WA

I derived the problem , but it always says WA. I don't know why

The program like this

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

#define PI 2*acos(0)
#define sqrt_result sqrt(3)
void main()
{
float length,a,result_A,result_B,result_C;

while((scanf("%f",&length))!=EOF)
{
length=length*length;
result_A=(1+PI/3-sqrt_result)*length;
result_B=(PI/3-4+2*sqrt_result)*length;
result_C=(4-(2*PI)/3-sqrt_result)*length;

printf("%.3f %.3f %.3f\n",result_A,result_B,result_C);
}
}