View Code of Problem 104

#include<stdio.h>
#include<string.h>

int main()
{

int n,v1,v2,t;double ti;
while(scanf("%d%d%d%d",&n,&v1,&v2,&t)!=EOF)
{
if(v1<0)
{
if(v2>0)
{
printf("NO\n");
}
if(v2<0)
{
if(v1>v2)
{ti=n*1000.0/(v1-v2);
if(ti>t)
printf("NO\n");
else printf("%.2f",ti);

}
else printf("NO\n");
}
}
else{
if(v2<0)
{
ti=n*1000.0/(v1-v2);
if(ti>t)
printf("NO\n");
else printf("%.2f",ti);
}
else
{
if(v2>v1)
printf("NO\n");
else {ti=n*1000.0/(v1-v2);

if(ti>t)
printf("NO\n");
else printf("%.2f",ti);
}
}
}
}
}

Double click to view unformatted code.


Back to problem 104