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

Discussion of Problem 1084. Goat in the Garden

WA on test 1. I use C#, pls help
Posted by Timur 16 Oct 2008 01:29
namespace Ogorod
{
    using System;
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split(' ');
            double a = double.Parse(s[0]);
            double r = double.Parse(s[1]);
            double kozel=0;

            if ( 2*r <= a ) kozel = Math.PI * r * r;
            if (2 * a * a <= 4 * r * r) kozel = a * a;
            if((2*r > a) && (2 * a * a > 4 * r * r))
            {
                double sektor = r * r * Math.Acos((a * a) / (2 * (r * r)) - 1) / 2;
                double segment = sektor - (a / 2) * Math.Sqrt(r * r - (a * a / 4));
                kozel = Math.PI * r * r - 4 * segment;
            }
            Console.WriteLine("{0:F3}",kozel);
        }
    }
}
Re: WA on test 1. I use C#, pls help
Posted by penartur 16 Oct 2008 04:27
Instead of
Console.WriteLine("{0:F3}",kozel);
you should use
Console.WriteLine(kozel.ToString("F3").Replace(',', '.'));
or set locale to en-US.

Edited by author 16.10.2008 04:28
Re: WA on test 1. I use C#, pls help
Posted by Ilya (Vologda SPU) 1 Nov 2009 01:52
Break on a first test:
66.xxx instead of 95.xxx

Locale en-US is default in Timus Checking System (RTFM).