QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#361958#8511. Greek Casinoucup-team052#WA 0ms3984kbC++23565b2024-03-23 13:43:342024-03-23 13:43:34

Judging History

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

  • [2024-03-23 13:43:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3984kb
  • [2024-03-23 13:43:34]
  • 提交

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'