SHARE
TWEET

tarefa de InfraCom

a guest Aug 19th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. double fat(int n){
  6.     if(n == 0 || n == 1){
  7.         return 1;
  8.     }else{
  9.         return n*fat(n - 1);
  10.     }
  11. }
  12.  
  13. double comb(int n, int k){
  14.     double mult = 1;
  15.     for(int i = n ; i > n-k ; i--){
  16.         mult *= i;
  17.     }
  18.     return mult/fat(k);
  19. }
  20.  
  21. int main(){
  22.     int n;
  23.     while(cin >> n){
  24.        
  25.         double sum = 0;
  26.        
  27.         for(int i = 0 ; i <= 10 ; i++){
  28.             sum += comb(n, i)*pow(0.1, i)*pow(0.9, (n - i));
  29.         }
  30.        
  31.         printf("%4.4f\n", 1 - sum);
  32.     }
  33.  
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top