QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#450868 | #6829. It Takes Two of Two | PetroTarnavskyi# | WA | 22ms | 216972kb | C++20 | 1.6kb | 2024-06-22 18:58:04 | 2024-06-22 18:58:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 301;
db dpT[N][N][N];
int n;
db dp(int path, int edge, int isol)
{
if(path < 0 || edge < 0 || isol < 0)
return 0;
if(path == 0 && edge + isol <= 1)
return 0;
if(dpT[path][edge][isol] > -0.5)
return dpT[path][edge][isol];
int sum = 0;
db res = n * n;
res += isol * (isol - 1) * dp(path, edge + 1, isol - 2);
sum += isol * (isol - 1);
res += 4 * isol * edge * dp(path + 1, edge - 1, isol - 1);
sum += 4 * isol * edge;
res += 4 * isol * path * dp(path, edge, isol - 1);
sum += 4 * isol * path;
res += 4 * edge * (edge - 1) * dp(path + 1, edge - 2, isol);
sum += 4 * edge * (edge - 1);
res += 4 * path * edge * dp(path, edge - 1, isol);
sum += 4 * path * edge;
res += 4 * path * (path - 1) * dp(path - 1, edge, isol);
sum += 4 * path * (path - 1);
res += 2 * path * dp(path - 1, edge, isol);
sum += 2 * path;
//assert(0 < sum && sum <= n * n - 2 * n);
return dpT[path][edge][isol] = res / sum;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
FOR(i, 0, N)
FOR(j, 0, N)
FOR(k, 0, N)
dpT[i][j][k] = -1;
cin >> n;
cout << fixed << setprecision(9) << dp(0, 0, n) << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 7ms
memory: 216968kb
input:
1
output:
0.000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #2:
score: 0
Accepted
time: 8ms
memory: 216904kb
input:
2
output:
2.000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 22ms
memory: 216972kb
input:
3
output:
8.250000000
result:
ok found '8.2500000', expected '8.2500000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 12ms
memory: 216772kb
input:
4
output:
11.333333333
result:
ok found '11.3333333', expected '11.3333333', error '0.0000000'
Test #5:
score: 0
Accepted
time: 8ms
memory: 216960kb
input:
5
output:
17.048611111
result:
ok found '17.0486111', expected '17.0486111', error '0.0000000'
Test #6:
score: -100
Wrong Answer
time: 15ms
memory: 216800kb
input:
6
output:
26.489952904
result:
wrong answer 1st numbers differ - expected: '26.0340659', found: '26.4899529', error = '0.0175112'