QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369548#8511. Greek Casinowillow#WA 2ms8608kbC++171.0kb2024-03-28 14:17:092024-03-28 14:17:13

Judging History

你现在查看的是最新测评结果

  • [2024-03-28 14:17:13]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8608kb
  • [2024-03-28 14:17:09]
  • 提交

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'