Advertisement
torgiren

jelon2_v1

Oct 27th, 2020
1,906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3. #include<bits/stdc++.h>
  4. int main()
  5. {
  6.     unsigned long int A, B, C, T;
  7.     double D;
  8.     std::cin>>T;
  9.     for(int ti=0; ti<T; ti++)
  10.     {
  11.         std::cin>>A>>B>>C;
  12.  
  13.         double x=0;
  14.         double step=10;
  15.         int dir=0;
  16.         do
  17.         {
  18.             D = A * x + B * sin(x) - C;
  19.             //D = A * x + B * sin(x) + C;
  20.             if(D>0)
  21.             {
  22.                 if(dir>0) step/=2;
  23.                 dir=-1;
  24.                 x-=step;
  25.             }
  26.             else
  27.             {
  28.                 if(dir<0) step/=2;
  29.                 dir=1;
  30.                 x+=step;
  31.             }
  32.         } while(abs(D)>0.0000001);
  33.         std::cout<<std::fixed << std::setprecision(6)<<x<<std::endl;
  34.     }
  35.  
  36.  
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement