zoukankan      html  css  js  c++  java
  • Luogu1769 淘汰赛制_NOI导刊2010提高(01)(概率DP)

    (i)次位置在(pos_0 / 2^{i - 1})

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #define R(a,b,c) for(register int  a = (b); a <= (c); ++ a)
    #define nR(a,b,c) for(register int  a = (b); a >= (c); -- a)
    #define Max(a,b) ((a) > (b) ? (a) : (b))
    #define Min(a,b) ((a) < (b) ? (a) : (b))
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Abs(a) ((a) < 0 ? -(a) : (a))
    #define Swap(a,b) a^=b^=a^=b
    #define ll long long
    
    #define ON_DEBUG
    
    #ifdef ON_DEBUG
    
    #define D_e_Line printf("
    
    ----------
    
    ")
    #define D_e(x)  cout << #x << " = " << x << endl
    #define Pause() system("pause")
    #define FileOpen() freopen("in.txt","r",stdin);
    
    #else
    
    #define D_e_Line ;
    #define D_e(x)  ;
    #define Pause() ;
    #define FileOpen() ;
    
    #endif
    
    struct ios{
        template<typename ATP>ios& operator >> (ATP &x){
            x = 0; int f = 1; char c;
            for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-')  f = -1;
            while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
            x*= f;
            return *this;
        }
    }io;
    using namespace std;
    
    double f[11][2027];
    int won[2027][2027];
    int main(){
        int n;
        io >> n;
        int m = 1 << n;
        R(i,1,m){
        	R(j,1,m){
        		io >> won[i][j];
        	}
        }
        R(i,1,m){
        	f[0][i] = 1;
        }
        R(i,1,n){
        	R(j,1,m){
        		int pos = ceil((double)j / (double)(1 << (i - 1)));
        		pos = (pos & 1) ? pos + 1 : pos - 1;
    			R(k, pos * (1 << (i - 1)) - (1 << (i - 1)) + 1, pos * (1 << (i - 1))) {
    				f[i][j] += f[i - 1][j] * won[j][k] / 100 * f[i - 1][k];
    			}
        		
        	}
        }
        
        double maxx = 0.0;
        int ans;
        R(i,1,m){
        	if(f[n][i] > maxx){
        		maxx = f[n][i];
        		ans = i;
        	}
        }
        
        printf("%d", ans);
        return 0;
    }
    

  • 相关阅读:
    变量的创建和初始化
    HDU 1114 Piggy-Bank (dp)
    HDU 1421 搬寝室 (dp)
    HDU 2059 龟兔赛跑 (dp)
    HDU 2571 命运 (dp)
    HDU 1574 RP问题 (dp)
    HDU 2577 How to Type (字符串处理)
    HDU 1422 重温世界杯 (dp)
    HDU 2191 珍惜现在,感恩生活 (dp)
    HH实习 acm算法部 1689
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11256378.html
Copyright © 2011-2022 走看看