Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5.  
  6. double arr[100015][11-2];
  7. int main()
  8. {
  9.     //ios_base::sync_with_stdio(false);cin.tie(NULL);
  10.     /*
  11.     #ifndef ONLINE_JUDGE
  12.     freopen("input.cpp", "r" , stdin);
  13.     freopen("output.cpp" , "w" , stdout);
  14.     #endif // ONLINE_JUDGE
  15.     //*/
  16.     for(int i = 2 ; i <= 10 ; i++){
  17.         arr[100000][i-2] = (i * 1.0 / (i - 1));
  18.         for(int j = (100000-1) ; j > 0 ; j--){
  19.              double sum = 0.0;
  20.              for(int k = 1 ; k < i ; k++){
  21.                 sum = sum + arr[j + k][i-2];
  22.              }
  23.              arr[j][i-2] = (i*1.0/(i - 1))*(1 + 1.0 /i * sum );
  24.         }
  25.     }
  26.     int t;cin >> t;
  27.     while(t--){
  28.         int n , k;
  29.         cin >> n >> k;
  30.         printf("%.9lf\n" , arr[100001-n][k-2]);
  31.     }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement