QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#473685#6829. It Takes Two of Twoprime-idealWA 0ms3960kbC++201.2kb2024-07-12 13:06:112024-07-12 13:06:11

Judging History

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

  • [2024-07-12 13:06:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3960kb
  • [2024-07-12 13:06:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define RN return
#define forw(_,l,r) for(auto _=(l);_<(r);++_)
#define fors(_,r,l) for(auto _=(r);_>(l);--_)
// #define DEBUG if((cout<<"line:"<<__LINE__<<'\n'), 1)
#define DEBUG if(0)
// #define int ll
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

void read(){}
template<typename T,typename...Types>
void read(T& x, Types&...args){
  x=0; char c=' '; bool sgn=0;
  while(isspace(c))c=getchar();
  if(c=='-')c=getchar(),sgn=1;
  while(isdigit(c))x=10*x+c-'0',c=getchar();
  if(sgn)x=-x;
  read(args...);
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int NUM=210;
ld dp[NUM][NUM][NUM]={};
int n;
void calc(){
  forw(i,0,n+1)forw(j,0,n/2+1)forw(k,0,n/3+1){
    vector<tuple<int,int,int,int>> v={
      {i*(i-1)/2,i-2,j+1,k},{i*2*j,i-1,j-1,k+1},
      {i*2*k,i-1,j,k},{j*(2*j-2),i,j-1,k},
      {2*j*2*k,i,j-1,k},{k*(2*k-2),i,j,k-1},
      {k,i,j,k-1}};
    int sum=0;ld ret=n*n/2;
    for(auto [w,i1,j1,k1]:v){
      sum+=w,ret+=dp[i1+2][j1+2][k1+2]*w;
    }dp[i+2][j+2][k+2]=sum?ret/sum:0;//!
  }
}

int main()
{
  read(n);calc();
  printf("%.9Lf\n",dp[n+2][2][2]);
  RN 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3960kb

input:

1

output:

0.000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

2

output:

2.000000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3948kb

input:

3

output:

7.333333333

result:

wrong answer 1st numbers differ - expected: '8.2500000', found: '7.3333333', error = '0.1111111'