Luogu1769 淘汰赛制_NOI导刊2010提高(01)(概率DP)
第\(i\)次位置在\(pos_0 / 2^{i - 1}\)
#include
#include
#include
#include
#include
#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("\n\n----------\n\n")
#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() ;#endifstruct ios{templateios& 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;
} 
转载于:https://www.cnblogs.com/bingoyes/p/11256378.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
