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

Обсуждение задачи 1902. Нео-Венеция

Why don't workng !!?!?!??!?
Послано Daniel 13 окт 2012 17:07
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{

    double *a,*d;
    int n,t,s,i;
    float temp;
    cin>>n;
    if(n>=1 && n<=100)
    {
        cin>>t;
        if(t>=1 && t<=100)
        {
            cin>>s;
            if(s>= 360 && s<=1200)
            {
                a = new double[n];
                d = new double[n];
                for(i=0;i<n;i++)
                {
                    cin>>a[i];
                    if(i==1)
                    {
                        if(a[i] <= a[i-1])
                        {
                            return 0;
                        }
                    }

                }

                for(i=0;i<n;i++)
                {
                    temp = t/n;
                    if(s == a[i])
                    {
                        d[i] = a[i]+temp;
                    }
                    else if(s < a[i])
                    {
                        temp = temp/n;
                        d[i] = a[i]+temp;
                    }

                }
                cout.setf(ios::showpoint);
                for(i=0;i<n;i++)
                {
                    cout<<d[i]<<0<<0<<0<<endl;
                }
            }
            else
            {
                return 0;
            }
        return 0;}
    return 0;}




    return 0;
}
Re: Why don't workng !!?!?!??!?
Послано Berendea 31 дек 2012 00:09
First of all, you don't have to check if the input is correct, so the following lines are useless:
if(n>=1 && n<=100)

if(t>=1 && t<=100)

if(s>= 360 && s<=1200)

if(i==1) //this is wrong - I think the that the condition is i>=1
{
   if(a[i] <= a[i-1]){
      return 0;
   }
}

Then, n has nothing to do with t. So temp=t/n is not ok. (try: 3 60 600 600 630 631 to see why).

Imagine that you have 4 points: A,B,C,D. The distance (in time) between them is as it follows: B-A=s ,C-B=t, D-C=sn. So two gondolas that have the same speed, would meet in the point (A+D)/2.

Also, you may want to check http://www.cplusplus.com/reference/ios/ios_base/precision/ to see how you can set the floating-point precision.


That is (s+t+sn)/2.
Re: Why don't workng !!?!?!??!?
Послано panther.uz 11 апр 2013 03:24
thanks for test