ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1874. Football Goal

java AC not formula
Posted by esbybb 12 Jul 2015 09:45
package timus;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
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;

return  A*B + (A*h+B*l)/2.0;
}

static class FastScanner {
StringTokenizer st;

}

String next() {
while (st == null || !st.hasMoreTokens()) {
try {