#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int a[] = {1, 2, 3, 4, 5, 6, 20, 50, 100, 1000}; double b[] = {1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235, 5.7894594000345325, 13.789629635263326, 27.122962962962941, 267.12296296296188}; int main() { int T; cin >> T; while (T--) { int N; cin >> N; double ans = 0; while (N > 0) for (int i = 9; i >= 0; i--) if (a[i] <= N) { ans += b[i]; N -= a[i]; } printf("%.10f\n", ans); } }