It's name is Subway.I'v copied it and it's solution below,but cannot understand at the position '*';
###############################################
Subway
Subway trains are meant to move people as quickly, safely, and comfortably as possible from station to station. Although the train drivers' unions may not agree, computer operated trains accomplish these goals more effectively than human operated trains. You are to determine the optimal control strategy to move the train from one station to another within the constraints imposed by safety and comfort considerations, as well as the physical limitations of the train itself.
The parameters to the problem are all positive integers not greater than 1000.
d - the distance between stations, in metres
m - the maximum allowable speed of the train, in metres/sec
a - the maximum absolute acceleration of the train, in metres/sec2
j - the maximum absolute jerk, in metres/sec3
The train must be completely stopped at each station and must move in one direction at speeds not exceeding m. Acceleration can be positive (forward) or negative (backwards) but its absolute value must not exceed a. The last parameter, jerk, is the rate of change of acceleration in either direction. That is, acceleration cannot increase or decrease at greater than this rate. This parameter prevents toppling the standing passengers.
There are several test cases. For each test case, standard input has a single line with d, m, a, j. For each test case, standard output should contain a single line giving the minimum time in seconds, to the nearest 0.1 second, required to move between the stations.
Sample Input
1000 70 20 1
Output for Sample Input
31.7
#############################################
here is the solution code:
#include <stdio.h>
#include <math.h>
double D,M,A,J,jtime, jtimeaccellimit, jtimespeedlimit, jtimedistlimit,
atime, dist, delta, a, b, c, r;
double cubrt(double x) {
return (exp(log(x)/3));
}
main(){
freopen("in.txt","r",stdin);
while (4 == scanf("%lf%lf%lf%lf",&D,&M,&A,&J)) {
jtimeaccellimit = A/J;
jtimespeedlimit = sqrt(M/J);
jtimedistlimit = cubrt(D/2/J);
jtime = jtimeaccellimit;
if (jtimespeedlimit < jtime) jtime = jtimespeedlimit;
if (jtimedistlimit < jtime) jtime = jtimedistlimit;
atime = (M - J*pow(jtime,2))/A;
a = 0.5*A;
b = A*jtime + 0.5*J*pow(jtime,2); ////////////////////////******
c = J * pow(jtime,3) - D/2;
r = (-b + sqrt(b*b - 4*a*c))/2/a;
if (r < atime) atime = r;
dist = J * pow(jtime,3)
+ 0.5*J*pow(jtime,2)*atime + 0.5*A * pow(atime,2)
+ A * atime*jtime;
printf("%0.1lf\n",4*jtime+2*atime+2*(D/2-dist)/M);
}
}
why b is not J*pow(jtime,2)?Who can tell me?thanks.!!
about a problem.(I'v copied it and it's solution)
Post about everything you want - even if it is not related to programming or this site.
Moderator: Board moderators
-
- New poster
- Posts: 5
- Joined: Sun Jan 30, 2005 2:27 pm
Return to “Off topic (General chit-chat)”
Jump to
- Real Time Contests and Last Minute Information
- ↳ General
- ↳ Real Time Clarification
- ↳ Fixing Mistakes
- ↳ HOWTOs
- ↳ Bugs and suggestions
- New system
- ↳ FAQ
- ↳ Bugs and suggestions
- Let's make some programs!
- ↳ Other words
- ↳ Algorithms
- ↳ New features
- Help on the Problemset
- ↳ Volume 1 (100-199)
- ↳ Volume 2 (200-299)
- ↳ Volume 3 (300-399)
- ↳ Volume 4 (400-499)
- ↳ Volume 5 (500-599)
- ↳ Volume 6 (600-699)
- ↳ Volume 7 (700-799)
- ↳ Volume 8 (800-899)
- ↳ Volume 9 (900-999)
- ↳ Volume 10 (1000-1099)
- ↳ Volume 11 (1100-1199)
- ↳ Volume 12 (1200-1299)
- ↳ Volume 13 (1300-1399)
- ↳ Volume 14 (1400-1499)
- ↳ Volume 15 (1500-1599)
- ↳ Volume 16 (1600-1699)
- ↳ Volume 17 (1700-1799)
- ↳ Volume 100 (10000-10099)
- ↳ Volume 101 (10100-10199)
- ↳ Volume 102 (10200-10299)
- ↳ Volume 103 (10300-10399)
- ↳ Volume 104 (10400-10499)
- ↳ Volume 105 (10500-10599)
- ↳ Volume 106 (10600-10699)
- ↳ Volume 107 (10700-10799)
- ↳ Volume 108 (10800-10899)
- ↳ Volume 109 (10900-10999)
- ↳ Volume 110 (11000-11099)
- ↳ Volume 111 (11100-11199)
- ↳ Volume 112 (11200-11299)
- ↳ Volume 113 (11300-11399)
- ↳ Volume 114 (11400-11499)
- ↳ Volume 115 (11500-11599)
- ↳ Volume 116 (11600-11699)
- ↳ Volume 117 (11700-11799)
- ↳ Volume 118 (11800-11899)
- ↳ Volume 119 (11900-11999)
- ↳ Volume 120 (12000-12099)
- ↳ Volume 121 (12100-12199)
- ↳ Volume 122 (12200-12299)
- ↳ Volume 123 (12300-12399)
- ↳ Volume 124 (12400-12499)
- ↳ Volume 125 (12500-12599)
- ↳ Volume 126 (12600-12699)
- ↳ Volume 127 (12700-12799)
- ↳ Volume 128 (12800-12899)
- ↳ Volume 129 (12900-12999)
- ↳ Volume 130 (13000-13099)
- ↳ Volume 131 (13100-13199)
- Help on languages
- ↳ C
- ↳ C++
- ↳ Pascal
- ↳ Java
- Off Topic
- ↳ Off topic (General chit-chat)
- Category
- ↳ ACM ICPC Archive Board