QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#502779 | #4228. Double Sort | ZhouShang | WA | 0ms | 19848kb | C++20 | 1.3kb | 2024-08-03 13:49:31 | 2024-08-03 13:49:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i,a,b) for (int i = a; i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back
#define FS first
#define SD second
#define ary(k) array<int, k>
template<class A, class B> void cmx(A &x, B y) { x = max<A>(x, y);}
template<class A, class B> void cmn(A &x, B y) { x = min<A>(x, y);}
typedef pair<int, int> pii;
typedef vector<int> vi;
int n,m;
double c[10009][59],f[59][10009][59];
double C(int n,int m){
if(!(0<=n&&n<=10000&&0<=m&&m<=50))
return 0;
return c[n][m];
}
signed main() {
//cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
cin>>n>>m;
for(int i=0;i<=10000;i++)
for(int j=0;j<=min(50ll,i);j++)
c[i][j]=!j?1:c[i-1][j]+c[i-1][j-1];
for(int i=1;i<=n;i++)
for(int j=i;j<=m;j++){
for(int k=1;k<=i;k++)
f[i][j][k]=k;
for(int k=0;k<=i;k++){
double p=1.0*C(j-i,k)*C(i,k)/C(j,i);
if(p==0)
continue;
for(int l=1;l<=k;l++)
f[i][j][i-k+l]+=p*f[k][j-i][l];
}
}
for(int i=1;i<=n;i++)
cout<<f[n][m][i]<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 14804kb
input:
3 5
output:
1 2.3 4.5
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 19848kb
input:
5 17
output:
1.13138 2.74838 5.1831 8.85569 15
result:
wrong answer 1st numbers differ - expected: '1.1313833', found: '1.1313800', error = '0.0000029'