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;
    }
    

  • 相关阅读:
    Java集合框架知多少——干货!!!
    Java基础小记
    初识Java
    HTML5入门必知
    密码技术小结
    [MDK]Keil在下载程序一直提示更新J-Link
    Python 循环
    2021年7月14日
    bzoj 2653 middle (主席树+二分)
    bzoj 3932 [CQOI2015]任务查询系统 (主席树)
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11256378.html
Copyright © 2011-2022 走看看