10287 - Gifts in a Hexagonal Box

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

Post Reply
famousun
New poster
Posts: 6
Joined: Sun Sep 29, 2002 5:04 pm

10287

Post by famousun »

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 ;
}

}
Let's do things better
lonelyone
Learning poster
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

10287

Post by lonelyone »


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.
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel »

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.
lonelyone
Learning poster
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

Post by lonelyone »

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.
You are a great and nice guy.
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.
:o ... so, I want to ask someone how to solve it.
And now, I solve it and got accept.
Thanks a lot. I will remember your good will deeply.
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

10287 - Gifts in a Hexagonal Box

Post by helloneo »

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;
}
it works for sample inputs.. but WA..
plz give me any ideas..
Nazmul Quader Zinnuree
New poster
Posts: 42
Joined: Sun Jul 31, 2005 2:07 am
Location: SUST. Bangladesh
Contact:

Post by Nazmul Quader Zinnuree »

Though I have not yet got it Ac,
There exists some trigonometric relation....
i.e.
r1 = s * cos(PI / 6);
.
.
Your way is totally wrong...
Good luck!!
ayeshapakhi
Learning poster
Posts: 60
Joined: Sun Apr 16, 2006 7:59 pm

10287 test data

Post by ayeshapakhi »

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.
....
daveon
Experienced poster
Posts: 229
Joined: Tue Aug 31, 2004 2:41 am
Location: TORONTO, CANADA

Post by daveon »

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
Kallol
Learning poster
Posts: 100
Joined: Sun Nov 13, 2005 8:56 am

Post by Kallol »

why WA ?
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
Post Reply

Return to “Volume 102 (10200-10299)”