10287 - Gifts in a Hexagonal Box
Moderator: Board moderators
10287
My code is following :
why it's wrong I can find any problem but i ge WA
can any one give me some test floatings and answers let me try my code ?
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<iomanip>
using namespace std ;
const double pi = 3.1415926535 ;
void main()
{
float a,r1,r2,r3,r4 ;
while(cin>>a)
{
r1 = a * sin(pi/3) ;
r2 = a/(1+ 1/cos(pi/6)) ;
r3 = a * sin(pi/3)/2 ;
r4 = r1*sqrt(r1*r1 + a*a)/(2*r1 + sqrt(r1*r1 + a*a)) ;
printf("%.10f %.10f %.10f %.10f\n",r1,r2,r3,r4) ;
//cout<<setw(0)<<setprecision(10)<<r1<<" "<<r2<<" "<<r3<<" "<<r4<<endl ;
}
}
why it's wrong I can find any problem but i ge WA
can any one give me some test floatings and answers let me try my code ?
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<iomanip>
using namespace std ;
const double pi = 3.1415926535 ;
void main()
{
float a,r1,r2,r3,r4 ;
while(cin>>a)
{
r1 = a * sin(pi/3) ;
r2 = a/(1+ 1/cos(pi/6)) ;
r3 = a * sin(pi/3)/2 ;
r4 = r1*sqrt(r1*r1 + a*a)/(2*r1 + sqrt(r1*r1 + a*a)) ;
printf("%.10f %.10f %.10f %.10f\n",r1,r2,r3,r4) ;
//cout<<setw(0)<<setprecision(10)<<r1<<" "<<r2<<" "<<r3<<" "<<r4<<endl ;
}
}
Let's do things better
10287
http://acm.uva.es/p/v102/10287.html
Could somebody explain how to solve the 4 gifts in box.
I have no idea to find a solution.
Could someone give me a hint, please.
Thanks a lot.
You are a great and nice guy.sohel wrote:Join the diagonal and try to form equations..
.. you can then form addtional equations by joining the midpoint of one side to that of the opposite
.. then simply solve the unknown from the equations.
Hint: You won't need any bisection/newton method for this..
.. a close form should come.
Hah... well, your thought was the same as mine, but I thought there must be another solution to this problem, cause the final equation was so ugly.

And now, I solve it and got accept.
Thanks a lot. I will remember your good will deeply.
10287 - Gifts in a Hexagonal Box
Code: Select all
#include <stdio.h>
#include <math.h>
int main(){
double s, sqr3, r1, r2, r3, r4;
while (scanf("%lf", &s) > 0) {
sqr3 = sqrt(3.0);
r1 = s * sqr3 / 2.0;
r3 = r1 / 2.0;
r2 = s*2.0 / (2.0 + 4.0 / sqr3);
r4 = r2 * 3.0 / 3.712;
printf("%.10lf %.10lf %.10lf %.10lf\n", r1, r2, r3, r4);
}
return 0;
}
plz give me any ideas..
-
- New poster
- Posts: 42
- Joined: Sun Jul 31, 2005 2:07 am
- Location: SUST. Bangladesh
- Contact:
-
- Learning poster
- Posts: 60
- Joined: Sun Apr 16, 2006 7:59 pm
10287 test data
hi all,
would anyone pls send me some input/output for the prob 10287 circles in the hexagon.
i'll be very greatful to you;
thanks.
....
would anyone pls send me some input/output for the prob 10287 circles in the hexagon.
i'll be very greatful to you;
thanks.
....
Hi,
Code: Select all
input:
1000.000
2000.000
3000.000
4000.000
5000.000
6000.000
7000.000
8000.000
9000.000
10000.000
output:
866.0254037844 464.1016151378 433.0127018922 375.0152213405
1732.0508075689 928.2032302755 866.0254037844 750.0304426811
2598.0762113533 1392.3048454133 1299.0381056767 1125.0456640216
3464.1016151378 1856.4064605510 1732.0508075689 1500.0608853622
4330.1270189222 2320.5080756888 2165.0635094611 1875.0761067027
5196.1524227066 2784.6096908265 2598.0762113533 2250.0913280432
6062.1778264911 3248.7113059643 3031.0889132455 2625.1065493838
6928.2032302755 3712.8129211020 3464.1016151378 3000.1217707243
7794.2286340599 4176.9145362398 3897.1143170300 3375.1369920649
8660.2540378444 4641.0161513775 4330.1270189222 3750.1522134054
why WA ?
is my formula wrong?
plz anyone check it...
is my formula wrong?
plz anyone check it...
Code: Select all
#include<stdio.h>
#include<math.h>
#define PI 2*acos(0.0)
int main(void)
{
long double a,r1,r2,r3,r4;
while(scanf("%Lf",&a)==1)
{
r1=a*sin(PI/3.0);
r2=a*((sqrt(3))/(2+(sqrt(3))));
r3=(sqrt(3))*(a/4.0);
r4 = r1*sqrt(r1*r1 + a*a)/(2*r1 + sqrt(r1*r1 + a*a)) ;
printf("%.10Lf %.10Lf %.10Lf %.10Lf\n",r1,r2,r3,r4);
}
return 0;
}
Syed Ishtiaque Ahmed Kallol
CSE,BUET
Bangladesh
CSE,BUET
Bangladesh