ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1084. Пусти козла в огород

stupid but works :)
Послано pera-zdera 27 сен 2005 13:44
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cstdlib>
#include <math.h>
#define PI 3.141592653589793238462643383279502884197169399375
using namespace std;
int main(int argc, char** argv){
    double a, l, angle = 0.0;
    cin >> a >> l;
    if (l <= (a/2.0))
        printf("%0.3f", (l*l*PI));
    else if (l >= (a*sqrt(2.0)/2.0))
        printf("%0.3f", (a*a));
    else {
        while (l*cos(angle) > (a/2.0)) angle += 0.0000001;
        printf("%0.3f", 4.0*((a/2.0)*l*sin(angle)+(l*l*(PI/4.0-angle))));
    }
}
Re: stupid but works :)
Послано Cyclops 2 дек 2008 00:04
please explain :

else {
while (l*cos(angle) > (a/2.0)) angle += 0.0000001;
printf("%0.3f", 4.0*((a/2.0)*l*sin(angle)+(l*l*(PI/4.0-angle))));
}

i don't understand with your way of thinking to get that calculation..
please explain to me..
to Cyclops
Послано Imran Yusubov 7 авг 2009 12:19
His solution is not stupid instead it is great I tried with mathematic way to find l to the point where the circle crosess the rect but every time i got WA.

l*cos(angle) -that means the length to the point where the circle crosses the rect-s side.At the begining it is equals to r but as we increase angel the cos(angel) decreases the value and we find the exact length.
and here ("%0.3f", 4.0*((a/2.0)*l*sin(angle) we find the are of triangles and add the are of sectors +(l*l*(PI/4.0-angle))...that is all ..if you don't understand again contact me with the problem name.. imran_yusubov@yahoo.com
Cyclops писал(a) 2 декабря 2008 00:04
please explain :

else {
while (l*cos(angle) > (a/2.0)) angle += 0.0000001;
printf("%0.3f", 4.0*((a/2.0)*l*sin(angle)+(l*l*(PI/4.0-angle))));
}

i don't understand with your way of thinking to get that calculation..
please explain to me..

Edited by author 07.08.2009 12:19

Edited by author 07.08.2009 12:20
Re: to Cyclops
Послано lightstone 17 май 2013 03:34
Why woudn`t you just use acos(a/(l*2)) to get an angle? ( its arc cos in the triangle we get there)

|\
| \
|  \
|   \ l
|    \
|a/2  \
|      \
|_______\