QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55067 | #1777. Fortune From Folly | MIT01# | WA | 1ms | 3748kb | C++ | 1.7kb | 2022-10-12 08:32:18 | 2022-10-12 08:32:18 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define maxn 500005
#define mod 998244353
template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll ksm(ll a, ll b) {if (b == 0) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;}
using namespace std;
#define db long double
const int S = 70;
db res[S][S];
db cof[S][S];
int main() {
int n, k;
db p;
cin >> n >> k >> p;
const int md = (1 << n) - 1;
for (int i = 0; i <= md; i++) {
if (__builtin_popcount(i) >= k)
res[i][i] = 1,
res[i][md + 1] = 0;
else {
res[i][i] = 1,
res[i][md + 1] = -1,
res[i][((i << 1) + 1) & md] -= p,
res[i][(i << 1) & md] -= (1 - p);
}
}
for (int j = 0; j <= md; j++) {
for (int k = j; k <= md; k++)
if (res[k][j]) {
for (int u = 0; u <= md + 1; u++)
swap(res[j][u], res[k][u]);
break;
}
for (int i = 0; i <= md; i++) {
if (i == j) continue;
db cof = res[i][j] / res[j][j];
for (int k = 0; k <= md + 1; k++)
res[i][k] -= cof * res[j][k];
}
}
db ans = res[0][md + 1] / res[0][0]; ans *= -1;
printf("%.10lf\n", ans);
return 0;
}
/*
3
3 6 1 1 4 1 2 2 4 9 1 4 2 3 3 2 4 1 10 14 10 8 1 6 2 5 4 2 5 5 8 9 2 7 6 8 6 5 7 4
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3748kb
input:
2 1 0.0006
output:
0.0000000000
result:
wrong answer 1st numbers differ - expected: '1666.6666667', found: '0.0000000', error = '1.0000000'