QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#369548 | #8511. Greek Casino | willow# | WA | 2ms | 8608kb | C++17 | 1.0kb | 2024-03-28 14:17:09 | 2024-03-28 14:17:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
const int MAXN = 100005;
int n, w[MAXN], sum;
LD p[MAXN], dp[MAXN];
vector<int> d[MAXN];
void solve() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &w[i]);
sum += w[i];
}
for (int i = 1; i <= n; ++i) {
p[i] = (LD)w[i] / sum;
}
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; j += i) {
d[j].push_back(i);
}
}
for (int i = n; i >= 1; --i) {
for (int j = 2; j * i <= n; ++j) {
if (__gcd(i, j) > 1) continue;
LD cur = 0;
for (auto x : d[i]) {
cur += p[j * x];
}
dp[i] += cur * (dp[i * j] + 1);
}
LD cur = 0;
for (auto x : d[i]) {
cur += p[x];
}
dp[i] = (dp[i] + cur) / (1.0 - cur);
}
printf("%.10Lf\n", dp[1]);
}
int main() {
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 8608kb
input:
3 1 1 1
output:
3.5000000000
result:
ok found '3.500000000', expected '3.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 7892kb
input:
3 1 1 2
output:
3.6666666667
result:
ok found '3.666666667', expected '3.666666667', error '0.000000000'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 7924kb
input:
1337 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1.0148033917
result:
wrong answer 1st numbers differ - expected: '1.0183368', found: '1.0148034', error = '0.0034698'