|
|
It's very easy to calculate this integral. But if you don't know what's integral, there are solution In-first, i calculated a k k = (a^2 * b * pi / 8) (or a*a*b*0.39269908169872415480783042290994 :) ) In-second, you should calculate y (or other symbol) from 1 to -1 with division (if n = 5: 1, 3/5, 1/5, -1/5, -3/5, -1) In-third, calculate F(y) = y*(1 - y^2 / 3). (F(1) = 2/3) in-fourth, print k*(F(yi) - F(y(i-1))) in loop example: if n = 2: first calculate should be k*(F(1) - F(0)), second k*(F(0) - F(-1)) if n = 3: 1) k*(F(1) - F(1/3)); 2) k*(F(1/3) - F(-1/3)); 3) k*(F(-1/3) - F(1)) etc. Search for "Ellipsoidal cap volume" on the internet if you got stuck with this problem. You can find derivation of a formula needed for this problem. I had a program like that: while (x <= b/2) { .... x += dx } but it will fail test 1 1 100 (the last piece won't show). Changed to while (x <= b/2 + 0.000001) { .... x += dx } Got AC! Please give me test 11!!!=( 1) 14 14 5 => 149.422524 356.315250 425.279492 356.315250 149.422524 2) 66.001 99.9 2 => 113929.225834 113929.225834 3) 0.45 6.666 10 => 0.019790 0.053716 0.079160 0.096123 0.104605 0.104605 0.096123 0.079160 0.053716 0.019790 4) 1 1 1 => 0.523599
I really don't understand, why should I divide the answer by 8?.. UPD: Nevermind, got it. Edited by author 02.05.2014 17:23 In problem you are given full axis and if you don't want divide answer by 8, you must divide given a and b by 2 before counting integral Edited by author 06.10.2014 02:02 Edited by author 06.10.2014 02:02 BinaryMind, no, it's because your a and b is full lenght and width of ellipse, but you need half of a and half of b. printf("%0.6f", number) in c/c++ or writeln(number:0:6) in pascal p.s. checkout the other online training/judge website www.z-trening.com, it has more feedback when you submit a problem Note that scanf uses "%lf" to read double, but printf must use "%f". It looks like printf with "%lf" does not work on Windows, although it works on Linux. я пробовал интегрировать и аналитически и численно, выдает то что должен выдавать в примере, но вот AC так и нет if on simple test your answer is 141.82419374396696000000 373.90014714318562000000 528.61744940933136000000 605.97610054240431000000 605.97610054240431000000 528.61744940933136000000 373.90014714318562000000 141.82419374396696000000 just swap(a,b) and read carefully problem; =) This is my code... import java.util.Scanner; public class T_1562 { public static double a,b; public static void main(String[] args) { Scanner sc= new Scanner(System.in); a = sc.nextDouble(); b = sc.nextDouble(); b = b/2; a = a/2; int n = sc.nextInt(); double step = 2*b/n; double x = -b; while(x+step <= b){ System.out.printf("%.6f",Math.abs(F(x)-F(x+step))); System.out.println(); x = x+step; } } private static double F(double z){ return Math.PI*(a/b)*(a/b)*(b*b*z - z*z*z/3); } } Edited by author 12.09.2011 14:14 Can somebody tell me what is 14th test, please????? I also had WA 14, I just added some digits into PI can you help me, please give me test11 use something like that: Step := B/N; Z := -B/2; while 1e-6 < B/2 - Z do begin WriteLn(Volume(Z, Z+Step):0:6); Z := Z + Step; end; Maybe, i must to find V of ellipsoid! how ti find that? and the sector of ellipsoid!!! Integration will help you. what is test 9 different from previous eights ? could it be some number conversion error ? |
|
|