QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#362703 | #8511. Greek Casino | ucup-team135# | WA | 0ms | 3968kb | C++20 | 1.2kb | 2024-03-23 16:48:07 | 2024-03-23 16:48:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define app push_back
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)
#else
#define debug(...)
#endif
#ifdef LOCAL
#define __int128 long long
#endif // LOCAL
const int inf=1e18;
const int maxn=1e5+5;
double c[maxn];
int32_t main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;cin>>n;
double a[n+1];for(int i=1;i<=n;++i) {int x;cin>>x;a[i]=x;}
double s=accumulate(a,a+n+1,0LL);for(int i=1;i<=n;++i) {a[i]/=s;}
double b[n+1];for(int i=1;i<=n;++i) {for(int j=i;j<=n;j+=i) {b[j]+=a[i];}}
double ans[n+1]={0};
for(int d=n;d>=1;--d)
{
int mx=n/d;
for(int k=1;k<=mx;++k)
{
c[k]=b[k*d];
}
for(int k=1;k<=mx;++k)
{
for(int l=2*k;l<=mx;l+=k)
{
c[l]-=c[k];
}
}
for(int k=2;k<=mx;++k)
{
ans[d]+=((ans[k*d]+1)*c[k]);
}
ans[d]+=c[1];
ans[d]/=(1-c[1]);
}
cout<<setprecision(25)<<ans[1];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3884kb
input:
3 1 1 1
output:
3.5
result:
ok found '3.500000000', expected '3.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
3 1 1 2
output:
3.66666666666666651863693
result:
ok found '3.666666667', expected '3.666666667', error '0.000000000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3968kb
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:
nan
result:
wrong output format Expected double, but "nan" found