Language: C++

#include <bits/stdc++.h>

using namespace std;

double ans[301][301][301];
int count[4];

int dp(int a, int b, int c){
	double A=a,B=b,C=c;
	double odp=0;
	if (a<0 || b<0 || c<0){
		return -1;
	}
	if (ans[a][b][c]!=-1){
		return ans[a][b][c];
	}
	odp=(A/N*dp(a-1,b,c))+(B/N*dp(a+1,b-1,c))+(C/N*dp(a,b+1,c-1))+1;
	odp*=N;
	odp/=a+b+c;
	ans[a][b][c]=odp;
	return ans[a][b][c];
}

int main(){
	cin >> N;
	for (i=0;i<N;i++){
		cin >> a;
		count[a]++;
	}
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			for(k=0;k<N;k++){
				ans[i][j][k]=-1;
			}
		}
	}
	ans[0][0][0]=1;
	cout << fixed << setprecision(10) << dp(count[1],count[2],count[3]);
}

Compiler output:
a.cc: In function 'int dp(int, int, int)':
a.cc:17:16: error: 'N' was not declared in this scope
   17 |         odp=(A/N*dp(a-1,b,c))+(B/N*dp(a+1,b-1,c))+(C/N*dp(a,b+1,c-1))+1;
      |                ^
a.cc: In function 'int main()':
a.cc:25:16: error: 'N' was not declared in this scope
   25 |         cin >> N;
      |                ^
a.cc:26:14: error: 'i' was not declared in this scope
   26 |         for (i=0;i<N;i++){
      |              ^
a.cc:27:24: error: 'a' was not declared in this scope
   27 |                 cin >> a;
      |                        ^
a.cc:28:17: error: reference to 'count' is ambiguous
   28 |                 count[a]++;
      |                 ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:6:5: note:                 'int count [4]'
    6 | int count[4];
      |     ^~~~~
a.cc:30:13: error: 'i' was not declared in this scope
   30 |         for(i=0;i<N;i++){
      |             ^
a.cc:31:21: error: 'j' was not declared in this scope; did you mean 'jn'?
   31 |                 for(j=0;j<N;j++){
      |                     ^
      |                     jn
a.cc:32:29: error: 'k' was not declared in this scope
   32 |                         for(k=0;k<N;k++){
      |                             ^
a.cc:38:49: error: reference to 'count' is ambiguous
   38 |         cout << fixed << setprecision(10) << dp(count[1],count[2],count[3]);
      |                                                 ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:6:5: note:                 'int count [4]'
    6 | int count[4];
      |     ^~~~~
a.cc:38:58: error: reference to 'count' is ambiguous
   38 |         cout << fixed << setprecision(10) << dp(count[1],count[2],count[3]);
      |                                                          ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:6:5: note:                 'int count [4]'
    6 | int count[4];
      |     ^~~~~
a.cc:38:67: error: reference to 'count' is ambiguous
   38 |         cout << fixed << setprecision(10) << dp(count[1],count[2],count[3]);
      |                                                                   ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:6:5: note:                 'int count [4]'
    6 | int count[4];
      |     ^~~~~