• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-72  評論-126  文章-0  trackbacks-0
            以前就見過不少求期望的題,題意很直白,但是卻一直少不到思路做題
            今天lcy老師推薦我看了zjut一位大牛的文章
            http://bbs.zjut.com/viewthread.php?tid=1170233&extra=page%3D1
            終于略知一二了,找幾道概率題做做


            http://acm.hdu.edu.cn/search.php?field=problem&key=2262
            E(now) = (E(NEXT1) + E(NEXT2) +...+E(NEXTn))/n + 1
            每個相鄰點建方程,注意起點可以走到得邊才能建方程,不然會導致無解
            先floodfill找到起點可以走到得點,然后建方程,最后仍個高斯消元模板解把答案解出來

            http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1423
            同上一道一摸一樣的題

            http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1317
            這個需要構造,相隔位子數的轉換
            想在相鄰n,都向內飛的話n-2,都想外飛n+2,一個向左一個向右的話就保持n不變,所以有下列方程
            E[n] = E[n+2]/4 + E[n-2]/4 + E[n]/2 + 1

            http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2619
            此題極度郁悶,轉移方程已經推出來了,卻因為精度問題過不了
            第四個sample我試了三個模板,出來的答案都不一樣。。。。。
            用java可過
            http://acm.hdu.edu.cn/showproblem.php?pid=3058
            上體升級版,變成了多串匹配,建Tire圖的基礎上進行轉移
            一樣存在精度問題,用java可過

            http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2837
            因為電梯有上有下,我索性就把樓的高度加倍  n = n * 2 - 2
            那sample來說,0~10是向上的,10~20是向下的,20就是0,向上的話又變成1開始
            在第7和第13層會碰到鬼(我從0層開始,所以每個量都要-1)
            這樣就可以得到轉移方程
            E[i] = E[(i+j)%n]/6 + 1
                    for(i =0; i < n ; i ++) {
                        
            if(i == m ||  i == n-m) {
                            mat[i][i] 
            = 1;
                        } 
            else {
                            mat[i][i] 
            = 6;
                            mat[i][n] 
            = 6;
                            
            for(j = 1; j <= 6; j ++) {
                                mat[i][(i
            +j)%n] --;
                            }
                        }
                    }
            http://acm.hdu.edu.cn/showproblem.php?pid=1204
            這題很早就開始想了,現在才會做,公式如下:
            a = p * (1 - q);
            b = q * (1 - p);
            E[n] = E[n-1] * a + E[n+1] * b + E[n] * (1 - a - b);
            E[0] = 0;
            E[N+M] = 1;


            這兩道AC的代碼都超短,應該是公式題。。沒上邊幾道那么有意思。。。
            http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2949
            http://acm.pku.edu.cn/JudgeOnline/problem?id=3682


            獻上第一次寫的高斯消元模板
            若返回時false則無解
            /**************************************************
             *    mat里建好方程,增廣矩陣    n*(n+1)
             *    傳入方程個數
             *    答案保存在mat[i][i]中
            *************************************************
            */
            #include 
            "stdio.h"
            #include 
            "string"
            #define ab(a) (((a)>0)?(a):(-a))
            #define maxn 100
            #define eps 1e-10
            double mat[maxn][maxn];
            void swap(double &a,double &b) {double t = a;a = b;b = t;}
            bool Gauss(int n) {
                
            int i,j,row,idx;
                
            double maxx,buf;
                
            for(row = 0; row < n ; row ++) {
                    
            for(maxx = 0,i =row ; i < n ; i ++)
                        
            if(ab(mat[i][row]) > maxx)
                            maxx 
            = ab(mat[i][row]),idx = i;
                    
            if(maxx < eps)return false;
                    
            if(idx != row)    
                        
            for(j =0 ; j <= n ; j ++)
                            swap(mat[row][j],mat[idx][j]);
                    
            for(i = row + 1; i < n ; i ++)
                        
            for(buf=mat[i][row]/mat[row][row],j = row; j <= n ; j ++)
                            mat[i][j] 
            -= buf * mat[row][j];
                }
                
            for(i = n-1;i >= 0; i --) {
                    
            for(j = i +1; j < n ; j ++)
                        mat[i][n] 
            -= mat[i][j]*mat[j][j];
                    mat[i][i] 
            = mat[i][n]/mat[i][i];
                }
                
            return true;
            }

            posted on 2009-05-19 13:48 shǎ崽 閱讀(3911) 評論(10)  編輯 收藏 引用

            評論:
            # re: 概率題總匯 2009-08-20 14:52 | lxghost
            你怎么能上zjut的啊  回復  更多評論
              
            # re: 概率題總匯 2009-08-29 16:21 | ACM
            E[n] = E[n-1] * a + E[n+1] * b + E[n] * (1 - a - b);
            ==> (a + b)E[n] - aE[n-1] - bE[n + 1] = 0;
            ==>為什么在建增廣矩陣時是mat[i][i - 1] = -b, mat[i][i + 1] = -a,mat[i][i] = a + b; 而不是mat[i][i - 1] = -a, mat[i][i + 1] = -b, mat[i][i] = a + b;  回復  更多評論
              
            # re: 概率題總匯 2009-08-29 16:25 | ACMer
            2262我照你的思路建了高斯消元,不知為什么一直錯了?能幫我看看嗎?
            #include <iostream>
            #include <algorithm>
            #include <cstring>
            #include <cstdio>
            #include <cmath>
            using namespace std;
            const int MAXN = 20;
            struct point_T {
            int x, y;
            };
            point_T st, ed[MAXN * MAXN];
            char map[MAXN][MAXN];
            int board[MAXN][MAXN];
            int row, col, cnt;
            double mat[MAXN * MAXN][MAXN * MAXN];
            int dir[4][2] = { {1, 0}, {-1, 0}, {0, -1}, {0, 1} };
            bool ok(int x, int y) {
            return x >= 0 && x < row && y >= 0 && y < col && (map[x][y] == '@' || map[x][y] == '.' || map[x][y] == '$');
            }
            void floodfill(int x, int y) {
            board[x][y] = ++ cnt;
            for(int i = 0; i < 4; i ++) {
            int tx = x + dir[i][0];
            int ty = y + dir[i][1];
            if(ok(tx, ty) && board[tx][ty] == -1) {
            floodfill(tx, ty);
            }
            }
            }
            bool gauss(int n) {
            int i, j, row, idx;
            double buf, maxx;
            for(row = 0; row < n; row ++) {
            for(maxx = 0, i = row; i < n; i ++) {
            if(maxx < fabs(mat[i][row])) {
            maxx = fabs(mat[i][row]);
            idx = i;
            }
            }
            if(maxx == 0) return false;
            if(idx != row) {
            for(i = row; i <= n; i ++)
            swap(mat[row][i], mat[idx][i]);
            }
            for(i = row + 1; i < n; i ++) {
            buf = mat[i][row] / mat[row][row];
            for(j = row; j <= n; j ++)
            mat[i][j] -= buf * mat[row][j];
            }
            }
            for(i = n - 1; i >= 0; i --) {
            for(j = i + 1; j < n; j ++)
            mat[i][n] -= mat[i][j] * mat[j][j];
            mat[i][i] = mat[i][n] / mat[i][i];
            }
            return true;
            }
            int main() {
            int i, j, k, l, cn;
            while(scanf("%d%d", &row, &col) != EOF) {
            cn = 0;
            for(i = 0; i < row; i ++) {
            scanf("%s", map[i]);
            for(j = 0; j < col; j ++) {
            if(map[i][j] == '@') {
            st.x = i;
            st.y = j;
            }else if(map[i][j] == '$') {
            ed[cn].x = i;
            ed[cn].y = j;
            cn ++;
            }
            }
            }
            memset(board, -1, sizeof(board));
            cnt = -1;
            floodfill(st.x, st.y);
            for(i = 0; i < cn; i ++) {
            if(board[ed[i].x][ed[i].y] != -1)
            break;
            }
            if(i == cn) {
            printf("-1\n");
            continue;
            }
            memset(mat, 0, sizeof(mat));
            int now, tx, ty, num;
            for(i = 0; i < row; i ++) {
            for(j = 0; j < col; j ++) {
            if(board[i][j] != -1) {
            now = board[i][j];
            num = 0;
            for(k = 0; k < 4; k ++) {
            tx = i + dir[k][0];
            ty = j + dir[k][1];
            if(ok(tx, ty)) {
            num ++;
            mat[now][board[tx][ty]] = -1;
            }
            mat[now][now] = num;
            mat[now][cnt + 1] = num;
            }
            }
            }
            }
            for(i = 0; i < cn; i ++) {
            l = board[ed[i].x][ed[i].y];
            memset(mat[l], 0, sizeof(mat[l]));
            mat[l][l] = 1;
            }
            if(gauss(cnt + 1))
            printf("%.6lf\n", mat[board[st.x][st.y]][board[st.x][st.y]]);
            else
            printf("-1\n");
            }
            return(0);
            }


              回復  更多評論
              
            # re: 概率題總匯 2009-11-29 12:26 | torzmai
            能不能解釋一下hdu 1204的那個公式??  回復  更多評論
              
            # re: 概率題總匯 2010-05-16 10:35 | ilj
            您給的那位“zjut一位大牛的文章”的鏈接好像要zjut內網才能鏈接上的,麻煩您能發那篇文章給我看看嗎,謝謝。郵箱349335192@qq.com  回復  更多評論
              
            # re: 概率題總匯 2010-11-08 23:39 | JENSENMercedes34
            I opine that to get the <a href="http://bestfinance-blog.com/topics/credit-loans">credit loans</a> from creditors you should have a firm motivation. Nevertheless, once I have received a student loan, just because I was willing to buy a building.   回復  更多評論
              
            # re: 概率題總匯 2012-08-02 16:36 | 求 zjut一位大牛的文章
            matrix,yms@gmail.com 謝謝啦  回復  更多評論
              
            # re: 概率題總匯 2012-08-07 10:56 | song
            傻仔大哥,我也想看浙大牛人文章,可不可以給我也發一份
            462039091@qq.com  回復  更多評論
              
            # re: 概率題總匯 2013-04-18 10:45 | meander
            我也想看浙大牛人文章,可不可以給我也發一份776593191@qq.com。跪謝  回復  更多評論
              
            # re: 概率題總匯 2013-10-25 11:49 | Plumrain
            概率題感覺還沒入門T T,求看zjut大牛的文章,感謝樓主。lmh463896910@gmail.com  回復  更多評論
              
            怡红院日本一道日本久久| 人人狠狠综合久久亚洲| 久久99精品久久久久久动态图| 色妞色综合久久夜夜| 亚洲一级Av无码毛片久久精品| 久久无码中文字幕东京热| 国产精品乱码久久久久久软件| 久久精品国产精品亚洲精品| 亚洲午夜久久影院| 97精品久久天干天天天按摩| 久久久久久久尹人综合网亚洲| 国产69精品久久久久99| 婷婷五月深深久久精品| 久久精品国产99国产精品亚洲| 久久se这里只有精品| 日本福利片国产午夜久久| .精品久久久麻豆国产精品| 亚洲欧美日韩中文久久| 久久久久久午夜精品| 亚洲国产成人久久一区久久 | 久久久久人妻精品一区| 伊人久久大香线蕉精品不卡| 久久久久亚洲精品天堂久久久久久 | 无码日韩人妻精品久久蜜桃| 99久久99久久精品国产片| 日日狠狠久久偷偷色综合96蜜桃| 日本精品久久久久中文字幕8| 久久www免费人成看国产片| 久久精品免费大片国产大片| 欧美午夜精品久久久久久浪潮| 久久青青草原亚洲av无码| 久久最新免费视频| 久久亚洲日韩精品一区二区三区| 久久精品国产亚洲AV麻豆网站| 国产成人精品久久二区二区| av国内精品久久久久影院| 色综合色天天久久婷婷基地| 国内精品久久国产| 99久久国产热无码精品免费| 97精品久久天干天天天按摩| 久久伊人中文无码|