Some problems in probability and expectation collation

Source: Internet
Author: User
Tags cmath

---restore content starts---

Have a few expectations ... Do not do at all ... And then just fill up ... Or to find Vjudge on some of the topics to do ... Some water problems, put together feel a little better.

Lightoj 1027

Test instructions

    n Doors, each door has a weight and there are two options to go out or just take time to look for time to go out.

SOL:

The first question is still to be hit ...

Obviously we can make an equation and then solve it ...

It's gone.

  

/*==========================================================================# last Modified:2016-03-22 18:19# filename:3680.cpp# Description: ==========================================================================*/# Define me Acrossthesky #include <cstdio> #include <cmath> #include <ctime> #include <string> #inc (in)  Lude <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <set> #include <map> #include <stack> #include <queue> #include <vector> #define LOWBIT (x) (x) & (-X ) #define for (I,A,B) for ((i) = (a);(i) <= (b);(i) + +) #define FORP (I,A,B) for (int i= (a); i<= (b); i++) #define FORM (i,a,b ) for (int i= (a); i>= (b); i--) #define LS (A, a) (((a) + (b)) << 1) #define RS (A, B) (((a) + (c)) >> 1) #define GETLC (a) ch[(a)][0] #define GETRC (a) ch[(a)][1] #define MAXN 10010#define MAXM 100000 #define PI 3.1415926535898 #define _E 2. 718281828459 #define INF 1070000000 using namespaceStd typedef long Long LL;  typedef unsigned long long ull;     Template<class t> inline void read (t& num) {bool start=false,neg=false;     char c;     num=0;         while ((C=getchar ())!=eof) {if (c== '-') start=neg=true;             else if (c>= ' 0 ' && c<= ' 9 ') {start=true;         num=num*10+c-' 0 ';     } else if (start) break; } if (neg) num=-num; }/*==================split line==================*/int a[maxn];int gcd (int x,int y) {return y==0?x:gcd (y,x%y);} int main () {//freopen ("a.in", "R", stdin); int cas; read (CAS); Forp (I,1,cas) {printf ("Case%d:", i); int n; Read (n); int t=0,sum=0; Forp (i,1,n) {read (a[i]); T+=abs (A[i]); if (a[i]<=0) sum++;} int down=n-sum;if (down==0) printf ("inf\n"), else {int d=gcd (t,down);p rintf ("%d/%d\n", t/d,down/d);}}}

Lightoj 1030

  Test instructions

I've seen it before and it seems to have written ... Backward push is very silk ... Code other people's stickers do not stick it ... Don't put it on ...

Lightoj 1038

Test instructions

Petition on the problem, feeling with the first question nothing different, do not write ...

Lightoj 1079

Test instructions

Rob a bank;

Now give a probability p, and the number of banks N;

Then give the money that each bank can grab, and the probability of robbing the bank of being caught;

Ask in the case of the probability of being caught less than equals p, the maximum amount of money to rob;

SOL:

Just see still a little confused force, feel want not to hit duck or something ... Found n equals 100, a little silly ... Think of a half-day no idea to see the puzzle ... Then found that the money does not exceed 1w ....

Then you can get a backpack.

This question finally please the front of SB image ... We put the status as the first I bank Rob J money The probability of being arrested, and then DP can

Do not want to hit the code Qaq ...

Lightoj 1248

Test instructions: To a n face of the dice, each polygon points appear the same probability, to throw out all the desired number of faces.

SOL:

Feel the wind is a bit like doing the ghost animal problem ....

Expect Dafa ... Be sure to push backwards ...

Set Dp[i] For has thrown out I a different face value, but also to throw dp[i] times to throw out n different sides of the expected number, obviously dp[n] = 0, requires dp[0]

Dp[i] = 1+ i/n * Dp[i] + (n-i)/n * dp[i+1], which would have been thrown once plus the desired value of each state transition =>dp[i] = n/(n-i) + dp[i+1]

However, I still feel a lot of silk silks ...

Lightoj 1265

Test instructions

In the island of survival, there are T-head Tigers on the island, D-Deer, every day will appear randomly two mobs (including yourself), if there is a tiger, then you will be eaten, if the two tigers, two tigers will perish, other conditions you will survive.

When there is no tiger on the island, you are considered to be successful in life.

Ask you the maximum probability of survival success.

Sol

Feel nothing to say ... The code is more intuitive ...

Code:

    

#include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <ctime> #include <set> #include <map> #include <list> #include <queue> #include <string> #include <vector> #include <fstream> #include <iterator> #include <iostream> #include <algorithm> using namespace std; #define LL long long#define INF 0x3f3f3f3f#define MOD 1000000007#define eps 1e-6#define maxn 1010int t , d;double Solve () {    double ans = 0.0;    if (t% 2 = = 1) return ans;    Ans = 1.0;    if (t = = 0) return ans;    int x = t;    while (x)    {        ans *= 1.0 * (x-1.0)/(x + 1.0);        X-= 2;    }    return ans;} int main () {    int T;    int kcase = 0;    scanf ("%d", &t);    while (T--)    {        scanf ("%d%d", &t, &d);        printf ("Case%d:%.7lf\n", + + Kcase, solve ());    }    return 0;}

Some problems in probability and expectation collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.