Advertisement
Saleh127

Light OJ 1027 / Mathematical Expectation - Probability

Oct 25th, 2021
660
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***
  2.  created: 2021-10-25-22.24.39
  3. ***/
  4.  
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7. #define ll long long
  8. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  9. #define get_lost_idiot return 0
  10. #define nl '\n'
  11.  
  12. int main()
  13. {
  14.    ios_base::sync_with_stdio(0);
  15.    cin.tie(0);cout.tie(0);
  16.  
  17.  
  18.    test
  19.    {
  20.         ll n,m,i,j=0,k=0,l=0;
  21.  
  22.         cin>>n;
  23.  
  24.         ll a;
  25.  
  26.         for(i=0;i<n;i++)
  27.         {
  28.              cin>>a;
  29.              l+=abs(a);
  30.  
  31.              if(a<0) j++;
  32.              else k++;
  33.         }
  34.  
  35.         cout<<"Case "<<cs<<": ";
  36.  
  37.         if(j==n) cout<<"inf"<<nl;
  38.         else
  39.         {
  40.              m=__gcd(l,k);
  41.  
  42.              cout<<l/m<<"/"<<k/m<<nl;
  43.         }
  44.        
  45.        
  46.         ///Expectation = P(1)*T(1) + P(2)*T(2) + P(3)*T(3)
  47.         ///P =probability of choosing door
  48.         ///T =time to get out of the maze
  49.    }
  50.  
  51.  
  52.    get_lost_idiot;
  53. }
  54.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement