Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- #include<bits/stdc++.h>
- int main()
- {
- unsigned long int A, B, C, T;
- double D;
- std::cin>>T;
- for(int ti=0; ti<T; ti++)
- {
- std::cin>>A>>B>>C;
- double x=0;
- double step=10;
- int dir=0;
- do
- {
- D = A * x + B * sin(x) - C;
- //D = A * x + B * sin(x) + C;
- if(D>0)
- {
- if(dir>0) step/=2;
- dir=-1;
- x-=step;
- }
- else
- {
- if(dir<0) step/=2;
- dir=1;
- x+=step;
- }
- } while(abs(D)>0.0000001);
- std::cout<<std::fixed << std::setprecision(6)<<x<<std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement