Problem A div 1, #364

Revision en2, by CazadorDivino, 2016-07-24 02:33:31
#include<stdio.h>
double T;
int n, v1, v2, L, K;
int main(){
    int i, C;
    scanf("%d%d%d%d%d",&n,&L,&v1,&v2,&K);
    C = (n-1)/K+1;
    double bb = 0, ee = 1e15, LL;
    for(i=0;i<100;i++){
        T = (bb+ee)*0.5;
        LL = (T - T*(v2-v1)/(v1+v2)) * v2 * (C-1) + T * v2;
        if(LL > L){
            ee = T;
        }
        else bb = T;
    }
    printf("%.11lf\n", T + (L - v2*T)  / v1 );
}

Anyone can explain this code. Thank you very much.

Tags math, #364

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en7 English CazadorDivino 2016-07-24 03:43:54 23
en6 English CazadorDivino 2016-07-24 03:42:48 1 Tiny change: 'eglected._ " in this ' -> 'eglected._" in this '
en5 English CazadorDivino 2016-07-24 03:41:23 5
en4 English CazadorDivino 2016-07-24 03:40:44 4
en3 English CazadorDivino 2016-07-24 03:40:11 997
en2 English CazadorDivino 2016-07-24 02:33:31 3
en1 English CazadorDivino 2016-07-24 02:33:13 515 Initial revision (published)