Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <algorithm>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- #include <vector>
- #include <map>
- #include <set>
- #include <cmath>
- #include <ctime>
- #include <cassert>
- using namespace std;
- #define pb push_back
- #define mp make_pair
- #define sz(A) (int)(A).size()
- typedef long long LL;
- typedef long double LD;
- const int N = int(1e5 + 5), M = 55;
- LD dp[N][M];
- int main() {
- int t;
- scanf("%d", &t);
- for (int i = 0; i < N; i++)
- dp[i][0] = i;
- for (int j = 1; j < M; j++) {
- LD sum = 0;
- for (int i = 0; i < N; i++) {
- if (i)
- dp[i][j] = sum / i;
- sum += dp[i][j - 1];
- }
- }
- for (int i = 0; i < t; i++) {
- int n, k;
- scanf("%d%d", &n, &k);
- if (k >= M)
- printf("%.6lf\n", 0.0);
- else
- printf("%.6lf\n", double(dp[n][k]));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement