Advertisement
Guest User

Untitled

a guest
Jan 11th, 2018
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3.  
  4. int main() {
  5.   double l, r;
  6.   double pd = 0;
  7.   while (scanf("%lf%lf", &l, &r) == 2) {
  8.     if (l < -0.5) break;
  9.     double d = r - l;
  10.     double ctl = d * 2 + (d - pd) * 5;  // PD controller
  11.     pd = d;
  12.  
  13.     double ml = std::max(0.0, std::min(1.0, 1 - ctl));
  14.     double mr = std::max(0.0, std::min(1.0, 1 + ctl));
  15.     printf("%.4lf %.4lf\n", ml, mr);
  16.     fflush(stdout);
  17.   }
  18.   return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement