|
|
Can you give some tests? The stars coordinates aren't natural numbers? Why precision of 10^-5 is needed? Should the algorithm ignore cases when scalar product of normal vector of the plane and "star"-vector is negative (the angle between vectors will be 90<x<270 so star's rays won't reach solar battery of esp. this plane)? Integer output also works, but you need int64_t. Note that it is not enough for normal/star angle to be less than pi/2, you also need to have correct normal -- the one that is opposite to the fourth vertex. Why 2800 instead of 1400??? 21*1m^2+21*1m^2+1358*1m^2=1400 Watts because your answer must multiply on 2. Why 2800 instead of 1400??? 21*1m^2+21*1m^2+1358*1m^2=1400 Watts can you tell me your algoritm Because you agreed that you would inflate the result twofold. Read the man-in-black's offer again. I use such an algorithm:I take four normal vectors to four different surfaces of the "ship" as cross product of two vectors,which I take as two vectors between points creating these surfaces.The length of this vector is 2xsquare of the triangle created by these points. Then,as energy produced by one surface of the "ship" for one star can be counted as square(sq further) of the surface multiplied by length of the "star" vector and multiplied by absolute of cos between normal vector to the surface and "star" vector. abs of that cosinus is equal to abs of their scalar production divided by their length production.As sq*"star" vector length multiplied by 2 is equal to their length production,then the energy produced by one surface is equal to abs of their scalar production divided by 2.It's quite clear that if we sum energies produced by all surfaces we'll get 2x energy that's really got from this star,so we don't need to multiply it by 2 lately to get the power wished by "man in black".So,if we sum energies from all the stars we'll get resulting energy. I have checked and rechecked this algorithm several times,I also have rechecked the program several times,but I Haven't found any mistakes not in the program,nor in the algorithm,I also ran several tests and checked the results manually,so I'll be grateful to anyone who'll show me possible mistakes. Edited by author 01.03.2009 21:35 To find answer we realy need to find sum of all scalar products of normals and star vectors (its absolute values of course), then divide 2 and print out... I did it with long long - not int and not double I replaced int by long long and got the right result^_^ I have thought,for some reason,that int type'd be enough for summary power. Sorry 4 multi-posting Edited by author 01.03.2009 21:25 |
|
|