Show all threads Hide all threads Show all messages Hide all messages |

test case #27 | Choker | 1874. Football Goal | 20 Sep 2019 13:34 | 7 |

what is wrong with test #27 ? try 1 10000 answer 25007071.3178118650 25007071.3178118655 for 1 10000. Accurate enough, but still wrong answer on test case #27. In #27 system checks output format I changed my python solution print FLOATANS to print "%0.6f" % FLOATANS and get AC
*Edited by author 08.05.2013 14:10* I had wrong answer on test 27, but corrected it by using "long double" type There's my code #include <cmath> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char** argv) { ios_base::sync_with_stdio(0); long double a, b; cin >> a >> b; cout << setprecision(100) << fixed << (a*a + b*b)/4.0 + sqrtl(2.0)*a*b/2; } |

для тех, кто не знает геометрии | Vyacheslav Kim | 1874. Football Goal | 1 Aug 2018 00:37 | 3 |

Если вы такой же идиот в геометрии, как и я, то сделайте 2 вложенных тернарных поиска по углам и все пройдет :). Удачи FFFUUUU This is a bad solution. There is just a formula for maximum area Nah. Ternary search on coordinates works well too |

java AC not formula | esbybb | 1874. Football Goal | 12 Jul 2015 09:45 | 1 |

package timus; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.StringTokenizer; public class p1874 { static double a, b; public static void main(String[] args) throws FileNotFoundException { InputStream is = System.in; FastScanner sc = new FastScanner(new InputStreamReader(is)); a = sc.nextInt(); b = sc.nextInt(); double XP = 0.000000001; double edge = 26.819279181787458*2.0; double l = 0, r = edge; while (r - l > XP) { double m1 = l + (r - l) / 3, m2 = r - (r - l) / 3; if (f2(m1, edge) < f2(m2,edge)) l = m1; else r = m2; } System.out.println(String.format("%.7f",Math.min(f2(l, edge),f2(r,edge)))); }
static double f2(double alfa, double sum2) { double beta = sum2 - alfa; double alfaRad = Math.toDegrees(alfa); double betaRad = Math.toDegrees(beta);
double A = Math.cos(alfaRad)*a; double B = Math.cos(betaRad)*b;
double h = Math.sin(alfaRad)*a; double l = Math.sin(betaRad)*b; return A*B + (A*h+B*l)/2.0; }
static class FastScanner { BufferedReader br; StringTokenizer st; FastScanner(Reader in) { br = new BufferedReader(in); } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } } } |

What shape is the football gate? | Nodir NAZAROV Komiljonovich | 1874. Football Goal | 6 Feb 2014 22:44 | 3 |

I tried to figure it out, how 1 tree and two sticks with the length of 2 can form the area more than 4? The largest area would be rectangle. What is the trick on this problem, can anybody explain with Geometry language. Thanks. The key point of the problem statement is "She knew that the standard football goal was rectangular, but, being creative, she assumed that her goal could have the form of an arbitrary quadrangle." So, it may be not a rectangle. I tried trapezoid like: /| 2/_| | | 2|__| x and tried to maximize the function - f(x) for total area which answer is sqrt(3) and total area is ~4.33 How to get ~4.8 for the given test? |

What shape is the football gate? | Nodir NAZAROV Komiljonovich | 1874. Football Goal | 30 Jan 2014 20:15 | 1 |

I tried to figure it out, how 1 tree and two sticks with the length of 2 can form the area more than 4? The largest area would be rectangle. What is the trick on this problem, can anybody explain with Geometry language. Thanks.
*Edited by author 30.01.2014 20:18* |

Mathmatical solution | 198808xc | 1874. Football Goal | 21 Feb 2013 04:25 | 8 |

From the sample test and the test on board (a = 10000 and b = 1), I have worked out the solution by guessing, and ACed online. For input a and b, the solution is: (a ^ 2 + b ^ 2) / 4 + Sqrt(2) * a * b / 2 However, I could not find the proof for this. Any help or suggestion for me? Write your e-mail. I will help you. S = F(alfa, betta), where alfa is angle of stick a, and betta is angle of stick b. It it requirement for extremum of such function that both partial derivatives (dS/dalfa and dS/dbetta) is zeros. From these two equations you could find that angle between a and b is constant, regardless of their lengthes. Using new formula and getting it's derivative, it's quite simple to show that length from zero point to touching point between stick and tree and length between zero point and touching point between 2nd stick and ground is equal. Also we know hypotenuse of this rectangular isosceles triangle because we know a, b and angle between. S = sum of S of two totaly determined triangles and it is exactly the formula you wrote.
*Edited by author 30.01.2012 14:21* Thanks so much, to both Neofit and Anatoly. I have followed the ideas of Anatoly, and finished the proof. This is really a good geometric problem! Anatoly, could you explain how sticks should been placed in task example? I even couldn't imagine how to place 2 sticks to get total square more than 4 (rectangle). // S(x, a, b) + x * x / 4 max. // sqrt((x + a + b) * (x + a - b) * (x + b - a) * (a + b - x)) + x * x // 2*x + 1/2 * (-2x * (x * x - (a-b) * (a-b)) + 2x * (-x * x + (a+b) * (a+b))) / sqrt(...) = 0 // 2*x + (-x * (x * x - (a-b) * (a-b)) + x * (-x * x + (a+b) * (a+b))) / sqrt(...) = 0 // delete x // 2 + (2*(a*a + b*b) - 2*x*x) / sqrt(...) = 0 // 1 + ((a*a + b*b) - x * x) / sqrt(...) = 0 // x^2 - (a^2 + b^2) = sqrt(...) // (x^2 - (a^2 + b^2)) ^ 2 = (x ^ 2 - (a - b) ^ 2) * ((a + b) ^ 2 - x ^ 2) // y = x^2 // (a*a + b*b))^2 - 2*(a*a + b*b) * y + y*y = -y*y + (2*(a*a + b*b)) * y - (a*a - b*b) ^ 2 // 2*y*y - 4*(a*a + b*b)*y + 2*(a^4 + b^4) = 0 // y^2 - 2(a^2 + b^2)y + (a^4 + b^4) = 0 // D/2 = 2(ab)^2 // y = (a^2+b^2 (+-) ab*sqrt(2)) // Smax = (2y - (a^2+b^2)) / 4 = (a^2+b^2)/4 + ab/sqrt(2) printf("%.18lf\n", (a * a + b * b) / 4 + (a * b) / sqrt(2.0));
it's the part of my solution and explanation of this formula. My solution and explanation gets about 5-7 lines of text :)It's so easy Can you post the mathematical explanation of your solution? |

Mathematics behind the scene (proof) | KNIGHT0X300 | 1874. Football Goal | 21 Feb 2013 04:22 | 2 |

It is very tempting to start solving using angles. But I would advice you to start with distances from the origin along x and y directions (say x and y). Following steps should easily guide you to the answer. 1) Area = 1/2*(xy+ ab Sin(ArcCos([a^2+b^2-x^2-y^2]/[2ab]))) 2) Using partial derivatives show x=y 3) substitute x=y in area and using first derivative of area show that x^2= [a^2+b^2+sqrt(2)ab]/2 4) Substituting y=x and the result from (3) Area =[a^2+b^2]/4 + ab/sqrt(2)
*Edited by author 08.02.2013 15:38* 1)I can compute the partial derivative of the area function. How do you prove that x=y 2)I can compute the derivative of the area function with x=y but how do you prove that x^2= [a^2+b^2+sqrt(2)ab]/2 |

Need help with prove | exwRabbits_AlMag(VNTU) | 1874. Football Goal | 8 Feb 2013 15:41 | 2 |

The key for solution was realizing that the ends of the sticks was on the same distance from origin. How to prove that? I have a function F(angleA, angleB). I took derivatives dF/angleA and dF/angleB, they must be equal to zero. Then what? Refer to my new topic :) Cheers |

Ternary search works well | Alexey Dergunov [Samara SAU] | 1874. Football Goal | 12 Jul 2012 23:23 | 4 |

I thought that there will be presicion problems, but it turned out that ternary search works pretty well. There is a formula! It is so easy to find it using derivative! It is not so cool to solve this problem using ternary search! I tried but it was too difficult for me. Hmm, I spent about 3-5 minutes to find this formula :) |

1 Wrong | Fadeev.E.V | 1874. Football Goal | 22 Feb 2012 17:53 | 4 |

1 Wrong **Fadeev.E.V** 2 Jan 2012 04:43 Please tell me why I wrong? import java.util.*; import java.math.*; public class Program { public static void main (String arqs[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(),b = sc.nextInt();
double x = (a+Math.sqrt(a*a+2*b*b))/2; double S = (a+x)/2*Math.sqrt(b*b-(x-a)*(x-a)); System.out.printf("%.9f",S); } }
*Edited by author 02.01.2012 04:44* Hi, Can you please tell me how did you find this formula ? I have tried many times, but cannot find the solution. Thanks. Oh, all is very easy. Using derivative, you can find angle between sticks in which area has a maximum value. Just find stationary point of area function.
*Edited by author 12.02.2012 17:45* |

Need a help | Islam | 1874. Football Goal | 30 Oct 2011 17:12 | 2 |

Please, can anybody tell how to solve this problem, which algorithm is used, how could the answer of sample test be 4.828427125? maybe a maximum of (2xy+x*sqrt(a*a-x*x)+y*sqrt(b*b-y*y))/2 should do |

Precision | budbud | 1874. Football Goal | 22 Oct 2011 15:54 | 2 |

"The answer must be accurate to at least six fractional digits."
*Edited by author 22.10.2011 15:54* |