#include #include #include #include #include #include #include #include #include #include using namespace std; #define int long long int MOD = 1000000007; const int64_t CYCLES_PER_SEC = 2800000000; const double TIMELIMIT = 8.3; struct Timer { int64_t start; Timer() { reset(); } void reset() { start = getCycle(); } void plus(double a) { start -= (a * CYCLES_PER_SEC); } inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; } inline int64_t getCycle() { uint32_t low, high; __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high)); return ((int64_t)low) | ((int64_t)high << 32); } }; class XorShift { public: unsigned int x, y, z, w; double nL[65536]; XorShift() { init(); } void init() { x = 314159265; y = 358979323; z = 846264338; w = 327950288; double n = 1 / (double)(2 * 65536); for (int i = 0; i < 65536; i++) { nL[i] = log(((double)i / 65536) + n); } } inline unsigned int next() { unsigned int t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8; } inline double nextLog() { return nL[next() & 0xFFFF]; } inline int nextInt(int m) { return (int)(next() % m); } int nextInt(int min, int max) { return min + nextInt(max - min + 1); } inline double nextDouble() { return (double)next() / ((long long)1 << 32); } }; XorShift rnd; double calcSum(vector &res) { double r = 0; for (int i = 0; i < res.size(); i++) { r += sqrt(res[i]); } return r; } Timer timer; signed main() { cin.tie(0); ios::sync_with_stdio(false); int Q; cin >> Q; vector res; double sum = 0; double diff; for (int i = 0; i < Q; i++) { timer.reset(); double P; cin >> P; res.clear(); for (int i = 0; i < 29; i++) { res.push_back(100); } int a = (P - 10 * 29)* (P - 10 * 29); res.push_back(a); sum = calcSum(res); diff = abs(sum - P); double ss = sum - sqrt(res.back()); int c = 0; while (true) { int x = rnd.nextInt(29); int d = rnd.nextInt(5) - 2; if (res[x] + d > 0) { ss += sqrt(res[x] + d) - sqrt(res[x]); res[x] += d; a = (P - ss)*(P - ss) + 0.5; res.back() = a; sum = ss + sqrt(res.back()); } if (abs(sum - P) < 5e-11) break; //c++; } //cerr << "c=" << c << endl; //cerr <