|
|
back to board.001 AC solution without memoization . #include <bits/stdc++.h> using namespace std ; #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define mem(x,val) memset((x),(val),sizeof(x)) #define all(x) x.begin(),x.end() #define pb push_back #define mp make_pair #define PI acos(-1.0) const int INF = 1 << 29 ; typedef long long ll ; int N(int n , int k ) { if(n == 1) return k<10?1:0 ; int sum = 0 ; for(int i = 0 ;i<= 9 && i<=k ; i++){ sum+=N(n-1 , k-i) ; } return sum ; } int main() { int n ,sum = 0 , temp ; scanf("%d" ,&n) ; n/= 2 ;
for(int i = 0 ; i<=n*9 ;i++){ temp = N(n,i) ; sum+=(temp*temp) ; } printf("%d\n" , sum) ; return 0 ; } Re: .001 AC solution without memoization . Posted by Alex 6 Aug 2017 22:17 |
|
|