QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#153007 | #6829. It Takes Two of Two | qzez# | WA | 1ms | 3888kb | C++14 | 1.2kb | 2023-08-29 08:07:24 | 2023-08-29 08:07:25 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=200+5,M=100+5,K=600+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n;db dp[N][N],t[N][N];
void Solve(){
int i,j;
scanf("%d",&n);
if(n==1){puts("0.00000000");return;}
dp[n][0]=1;
db ans=0;
for(i=n;i;i--){
for(j=(n-i)/2;~j;j--)if(j||i==n){
db p=(i*(i-1)+2*j*(2*j-2)+2*2*j*i)*1.0/n/n;
t[i][j]=p=1/p;
p=i*(i-1)+2*j*(2*j-2)+2*2*j*i;
if(i>=2) dp[i-2][j+1]+=dp[i][j]*i*(i-1)/p;
if(j>=2) dp[i][j-1]+=dp[i][j]*2*j*(2*j-2)/p;
if(i&&j) dp[i-1][j]+=dp[i][j]*2*2*j*i/p;
ans+=dp[i][j]*t[i][j];
// cerr<<i<<' '<<j<<' '<<dp[i][j]<<' '<<t[i][j]<<'\n';
}
}
printf("%.8lf\n",ans+(n>2?n*n/2.0:0));
}
int main(){
int t;
// scanf("%d",&t);
t=1;
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
input:
1
output:
0.00000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3888kb
input:
2
output:
2.00000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
3
output:
8.25000000
result:
ok found '8.2500000', expected '8.2500000', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3848kb
input:
4
output:
14.13333333
result:
wrong answer 1st numbers differ - expected: '11.3333333', found: '14.1333333', error = '0.2470588'