QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361958 | #8511. Greek Casino | ucup-team052# | WA | 0ms | 3984kb | C++23 | 565b | 2024-03-23 13:43:34 | 2024-03-23 13:43:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int s[N], w[N], mu[N];
int n, sum;
long double ans;
int main() {
scanf("%d", &n);
mu[1] = 1;
for (int i = 1; i <= n; i++) {
for (int j = i * 2; j <= n; j += i) mu[j] -= mu[i];
}
for (int i = 1; i <= n; i++) {
scanf("%d", &w[i]);
for (int j = i; j <= n; j += i) s[j] += w[i];
sum += w[i];
}
for (int i = 1; i <= n; i++) {
long double p = (long double)s[i] / sum;
p = 1 / (1 - p);
ans += p * mu[n / i];
}
printf("%.9Lf\n", ans - 1);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
input:
3 1 1 1
output:
3.500000000
result:
ok found '3.500000000', expected '3.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
3 1 1 2
output:
3.666666667
result:
ok found '3.666666667', expected '3.666666667', error '0.000000000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3984kb
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:
299.016306555
result:
wrong answer 1st numbers differ - expected: '1.0183368', found: '299.0163066', error = '292.6320263'