ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

1084
Posted by Fadeev.E.V 26 Aug 2011 18:20
http://acm.timus.ru/problem.aspx?space=1&num=1084


Why is not correct. There is only one test.
My code:

import static java.lang.Math.sqrt;
import static java.lang.Math.pow;
import static java.lang.Math.acos;
import static java.lang.Math.round;

import java.util.Scanner;
import java.util.*;

public class gf {
        public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        Formatter fmt = new Formatter();
        final double PI = 3.141;
        double angle = 0.000;
        double S = 0.000, S_sector = 0.000, S_triangle = 0.000, S_segment_1 = 0.000;


        int a = sc.nextInt();

        int r = sc.nextInt();

        if (r >= sqrt(pow(a / 2, 2) + pow(a / 2, 2)))
             S = pow(a, 2);
         else
        if (r <= (a / 2))
             S = PI * pow(r, 2);
         else {
            S_triangle = a * (sqrt(pow(r, 2) - pow((a / 2), 2)) / 2 ); //вычисляем площадь треугольника

            angle = acos((a / 2) / r); //находим угол сектора, который описывает дугу

            S_sector = (PI * (pow(r, 2)) * angle) / 180; //вычисляем площадь этого сектора

            S_segment_1 = S_sector - S_triangle; //вычисляем площадь сегмента

            S = (PI * pow(r,2)) - (4 * S_segment_1); //вычисляем искомую площадь
            }
        fmt.format("%.3f",S);
         System.out.println( fmt);
      }
}



Edited by author 26.08.2011 18:24

Edited by author 26.08.2011 18:25

Edited by author 26.08.2011 18:30
Re: 1084
Posted by Fadeev.E.V 26 Aug 2011 22:27
please, help.