Skip to content

Instantly share code, notes, and snippets.

@AKASH-ALAM
Last active November 16, 2022 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AKASH-ALAM/b5cf71444fd338de713d340c1d1a1481 to your computer and use it in GitHub Desktop.
Save AKASH-ALAM/b5cf71444fd338de713d340c1d1a1481 to your computer and use it in GitHub Desktop.
TRIGALGE - Easy Calculation
/**
* Author : Pnictogen
* Task :
* Algo :
**/
#include <bits/stdc++.h>
#define endl '\n'
#define sqr(x) (x) * (x)
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) ((x/gcd(x,y)) * y)
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define prec(x) fixed<<setprecision(x)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define unsyncIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
using ull = unsigned long long;
const ld PI = acos((ld) - 1);
const int MOD = 1e9 + 7;
const ll INF = 2e18 + 1;
const ld EPS = 1e-7;
const int MX = 2e5;
#ifdef LOCAL
#include"debug.h"
#else
#define debug(...)
#endif
void solve() {
ld a, b, c; cin >> a >> b >> c;
ld low = 0.0, high = c, mid, eq;
cout << fixed << setprecision(6);
while (low <= high) {
mid = (low + high) / 2.0;
eq = (a * mid) + (b * sin(mid));
if (eq < c) low = mid + EPS;
else if (eq > c) high = mid - EPS;
}
cout << mid << endl;
}
int main() {
#ifdef LOCAL
clock_t tStart = clock();
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
unsyncIO;
int t = 1; cin >> t;
while (t--) {
solve();
}
#ifdef LOCAL
cerr << "\nRuntime: " << (ld) (clock() - tStart) / CLOCKS_PER_SEC << " Seconds" << endl;
#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment