Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)
#define INF (1 << 30)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
double r[1024], dp[11][1024];
double win(int p, int q) {
return 1. / (1. + pow(10., (q - p) / 400.));
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int k;
cin >> k;
rep(i, (1 << k)) cin >> r[i];
rep(i, (1 << k)) dp[0][i] = 1.0;
rep(i, k) {
rep(j, (1 << k)) rep(l, (1 << k)) {
if((j >> i) != (l >> i) && (j >> (i + 1)) == (l >> (i + 1))) {
dp[i + 1][j] += dp[i][j] * dp[i][l] * win(r[j], r[l]);
}
}
}
rep(i, (1 << k)) printf("%.9f\n", dp[k][i]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.