Fusing ParticlesProblem code: ICODER2 |
All submissions for this problem are available.
Imagine a n-sided regular polygon. At each vertex of the polygon lies a particle 'x'. Now, in a hypothetical experiment, starting at time = 0s, each particle 'x' travels on the sides of polygon in clockwise manner with a constant speed. Therefore, a square with vertices A, B, C, D ( in clock-wise direction) , a particle 'x' starting at 'A' would move along side 'AB' and reach 'B', then travel along 'BC' and reach 'C' and so on.
Each particle has same properties except that they may or may not start with the same constant speed. Thus, a particle with a higher speed would ultimately collide into the particle in front of it when going in clockwise manner. Collision of two or more particles at a given time instant results in a fusion, thus giving rise to a single particle with same properties except that its speed is the average of the speeds of the colliding particles. The experiment stops at time = t, when a stability point is reached i.e. when there is no chance of further fusion.
Now given the total sides, length of the side of the regular polygon and speeds of different particles, you have to find 't' i.e. the time taken to reach to the stability point and the final speed of the particle(s).
Notes
- If the distance between two particles is less that 0.0000001 mts i.e. 1e-7 or 10 ^ -7, collision occurs.
- Particles follow the general kinematics rule( except for the collision rules stated above ).
- Assume there is no friction or air resistance.
- Assume that the time taken at edges and the time taken for fusion is negligible.
Constraints
- All calculations are to be done in meters and seconds.
- Use maximum precision wherever possible.
Input
1. Number of test cases = 'T' ( 1 <= T <= 500 ).
2. For each test case, first line contains number of sides in regular polygon = 'D' ( 3 <= D <= 50 ).
3. Next line contains length of a side = 'L' ( integer ) ( 5 <= L <= 10000 ) in meters.
4. Next input contains speed of all D particles ( in clockwise direction, each speed on new line ) = 'S' ( integer ) ( 5 <= S
<= 1000 ) in meters per second.
Output
1. Each line of output contains total time 't' taken for the experiment to reach the stability point followed by a space and the final speed of the particle(s). Give your answer up to 6 decimal places.
Example
Input: 2 4 100 500 200 300 400 3 100 200 200 200 Output: 3.000000 350.000000 0.000000 200.000000
| Author: | csirubix |
| Date Added: | 20-03-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

I was just testing the
I was just testing the problems, my submission won't count. You can post your queries here...
how many particles are
how many particles are allowed?
u have taken 3 !!!!
u have taken 3 !!!!
The contest has been extended
The contest has been extended up to 6 p.m.
that is clear enough, read
that is clear enough, read the problem carefully
at each vertex of the polygon
at each vertex of the polygon lies a particle, is it clear now?
thanks got it
thanks got it
The contest has been extended
The contest has been extended up to 8 p.m.
how come the secondĀ case is
how come the secondĀ case is possibleĀ when they are having equal speed ,time cant be zero?
why it can't be zero, time
why it can't be zero, time taken to reach stability point is 0 seconds. Its clear enough...
read this "stability point is
read this "stability point is reached i.e. when there is no chance of further fusion" i hope its clear now.
can u give one more test
can u give one more test case?
when will the results be
All codes are public, you may
All codes are public, you may view them. Also the codes would be verified and then the winners would be declared. People with the same code would be disqualified.