Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define d(x) cout << #x << " = " << (x) << endl;
- #define fr freopen("in.txt", "r", stdin);
- #define fw freopen("out.txt", "w", stdout);
- #define mem(x) memset((x), 0, sizeof((x)));
- #define pb push_back
- #define LL long long
- #define fastIO ios_base::sync_with_stdio(false)
- #define sf scanf
- #define pf printf
- #define SQR(x) ((x)*(x))
- #define sc1(x) scanf("%d", &x)
- #define scb(x, y) scanf("%d %d", &x, &y)
- #define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z)
- #define FOR(i, x, y) for(int i=int(x); i<int(y); i++)
- #define ROF(i, x, y) for(int i=int(x-1); i>=int(y); i--)
- #define all(c) (c.begin(), c.end())
- #define unq(v) sort(all(v)), (v).erase(unique(all(v)),v.end())
- #define EPSILON (1.0E-9)
- #define siz 100000
- double p,q,r,s,t,u;
- double func(double x){
- double part1 = u;
- double part2 = t*x*x;
- double part3 = s*tan(x);
- double part4 = r*cos(x);
- double part5 = q*sin(x);
- double part6 = p*exp(-x);
- // return part1 + part2 + part3 + part4 + part5 + part6;
- return p*exp(-x) + q*sin(x) + r*cos(x) + s*tan(x) + t*x*x + u;
- }
- int main(){
- #ifndef ONLINE_JUDGE
- clock_t tStart = clock();
- freopen("in.txt", "r", stdin);
- freopen("out.txt", "w", stdout);
- #endif
- while(cin >> p >> q >> r >> s >> t >> u){
- double a = 0.0;
- double b = 1.0;
- double c = a;
- if (func(a) * func(b) > EPSILON){
- cout << "No solution" << endl;
- continue;
- }
- int it = 100;
- while(it--){
- c = (a+b)/2.0;
- if(func(c)*func(a) <= 0){
- b = c;
- }
- else if(func(c)*func(b) < 0){
- a = c;
- }
- }
- printf("%0.4lf\n", c);
- }
- #ifndef ONLINE_JUDGE
- printf("\n>>Time taken: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement