|
| 1 | +///////////////// PRANTA KUMER PANDIT /////////////// |
| 2 | +// Test Case Less Template || |
| 3 | +// || |
| 4 | +// BANGLADESH UNIVERSITY OF BUSINESS AND TECHNOLOGY || |
| 5 | +// INTAKE 52 || |
| 6 | +// DEPARTMENT OF CSE || |
| 7 | +//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
| 8 | +// So, WELCOME TO ISHAN'S PARADISE // |
| 9 | +// (-.-) Want to be a Secret tool of next ICPC (-.-) // |
| 10 | + |
| 11 | +#include <bits/stdc++.h> |
| 12 | +using namespace std; |
| 13 | +typedef long long ll; |
| 14 | +#define pb push_back |
| 15 | +#define yes cout<<"YES"<<endl |
| 16 | +#define no cout<<"NO"<<endl |
| 17 | +#define all(x) (x).begin(), (x).end() |
| 18 | +#define gcd(a,b) __gcd(a,b) |
| 19 | +#define lcm(a,b) (a*b)/__gcd(a,b) |
| 20 | +#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); |
| 21 | +void solve() { |
| 22 | + long double pkp; |
| 23 | + cin >> pkp; |
| 24 | + |
| 25 | + const long double A = 12500.0L; |
| 26 | + const long double B = 50000.0L; |
| 27 | + const long double C = 150000.0L; |
| 28 | + |
| 29 | + const long double limit = 1e-12L; |
| 30 | + |
| 31 | + auto taxFromIncome = [&](long double I)->long double { |
| 32 | + if (I <= A) return 0.0L; |
| 33 | + if (I <= B) return (I - A) * 0.20L; |
| 34 | + if (I <= 100000.0L) return (B - A) * 0.20L + (I - B) * 0.40L; |
| 35 | + if (I <= 125000.0L) return (B - A) * 0.20L + (100000.0L - B) * 0.40L + (I - 100000.0L) * 0.60L; |
| 36 | + if (I <= C) return (B - A) * 0.20L + (100000.0L - B) * 0.40L + (125000.0L - 100000.0L) * 0.60L + (I - 125000.0L) * 0.40L; |
| 37 | + return (B - A) * 0.20L + (100000.0L - B) * 0.40L + (125000.0L - 100000.0L) * 0.60L + (C - 125000.0L) * 0.40L + (I - C) * 0.45L; |
| 38 | + }; |
| 39 | + |
| 40 | + long double arkta = 0.0L; |
| 41 | + |
| 42 | + if (pkp <= limit) { |
| 43 | + arkta = 0.0L; |
| 44 | + } else { |
| 45 | + long double lo = 0.0L, hi = 1e18L; |
| 46 | + if (pkp <= 47500.0L) hi = 1e6L; |
| 47 | + else hi = 1e12L; |
| 48 | + |
| 49 | + for (int iter = 0; iter < 200; ++iter) { |
| 50 | + long double mid = (lo + hi) * 0.5L; |
| 51 | + long double t = taxFromIncome(mid); |
| 52 | + if (t < pkp) lo = mid; |
| 53 | + else hi = mid; |
| 54 | + } |
| 55 | + arkta = (lo + hi) * 0.5L; |
| 56 | + } |
| 57 | + |
| 58 | + cout << fixed << setprecision(2) << arkta << "\n"; |
| 59 | +} |
| 60 | + |
| 61 | +int main() { |
| 62 | + optimize(); |
| 63 | + int lol; |
| 64 | + cin >> lol; |
| 65 | + while (lol--) { |
| 66 | + solve(); |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +// THANKS // |
0 commit comments