Cod sursa(job #1886720)

Utilizator CodrutLemeniCodrut Lemeni CodrutLemeni Data 21 februarie 2017 09:10:44
Problema Pod Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.11 kb
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#define N 1010
#define LMAX 50
#define MOD 9901

using namespace std;

int lips [ N ];
int steps [ LMAX ];

int main(){
    int n , m , k , i , cr ;

    freopen("pod.in","r",stdin);
    freopen("pod.out","w",stdout);

    scanf("%d %d %d",&n ,&m ,& k);

    for ( i = 0 ; i < m ;i++) {
        scanf("%d",&lips[ i ] );
    }
    sort ( lips ,lips + m );

    steps [ k ] = 1 ;
    int ActualWoodIndex = 0 ,last1 ,lastk ;
    for ( i = 1 ,cr = k + 1 , last1 = k , lastk = 1 ; i <= n ; i ++,cr ++ ){
        if ( cr == LMAX ){
            cr = 0 ;
        }
        if ( last1 == LMAX ){
            last1 = 0 ;
        }
        if ( lastk == LMAX ){
            lastk = 0 ;
        }

        steps [ cr ] = 0 ;
        if ( lips [ ActualWoodIndex ] == i ){
            steps [ cr ] = 0 ;
            ActualWoodIndex ++ ;
            continue ;
        }

        steps [ cr ] += steps [ last1 ] + steps [ lastk ];
        steps [ cr ]%= MOD ;
    }

    printf("%d",steps [ cr ] );

    return 0;
}