10209 - Is This Integration ?
Moderator: Board moderators
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
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
-
- New poster
- Posts: 7
- Joined: Wed Dec 12, 2001 2:00 am
- Location: Bangladesh
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);
}
}
#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);
}
}
-
- A great helper
- Posts: 284
- Joined: Thu Feb 28, 2002 2:00 am
- Location: Germany
- Contact:
-
- New poster
- Posts: 27
- Joined: Sun Jul 07, 2002 6:46 pm
- Location: Campina Grande - Brazil
- Contact:
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;
}
#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;
}
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?
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 */
);
}
}
-
- System administrator & Problemsetter
- Posts: 399
- Joined: Sat Jan 12, 2002 2:00 am
use higher precision
Neither float nor double, the problem is the precision of the constant that your're using to multiply a
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);
}
}
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);
}
}