ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1044. Lucky Tickets. Easy!

.001 AC solution without memoization .
Posted by Rafat Islam 2 Nov 2016 20:29
#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
Thx a lot!
I see it the same method as in http://ega-math.narod.ru/Quant/Tickets.htm
its a pity, but i dont understand it(