dp
View Code
#include < iostream > #include < cstdio > #include < cstdlib > #include < cstring > using namespace std; int f[ 6 ][ 50 ]; int main(){ // freopen("t.txt", "r", stdin); memset(f, 0 , sizeof (f)); f[ 0 ][ 0 ] = 1 ; for ( int i = 1 ; i <= 5 ; i ++ ) for ( int j = 0 ; j <= 9 * i; j ++ ) for ( int k = 0 ; k <= 9 ; k ++ ) { if (k > j) break ; f[i][j] += f[i - 1 ][j - k]; } int n; scanf( " %d " , & n); n /= 2 ; int ans = 0 ; for ( int i = 0 ; i <= n * 9 ; i ++ ) ans += f[n][i] * f[n][i]; printf( " %d " , ans); return 0 ;}