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 1902. Neo-Venice

Why don't workng !!?!?!??!?
Posted by Daniel 13 Oct 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 !!?!?!??!?
Posted by Berendea 31 Dec 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 !!?!?!??!?
Posted by panther.uz 11 Apr 2013 03:24
thanks for test