Cod sursa(job #3376940)

Utilizator STUPIDDEKUBach Bao Chau STUPIDDEKU Data 20 noiembrie 2026 15:28:09
Problema Combinari Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.79 kb
#include <bits/stdc++.h>
#define in  fin
#define out fout

using namespace std;
const int NMAX = 1e4 + 5;
const int MOD = 10007;

int dp[NMAX][NMAX];

ifstream fin("desc.in");
ofstream four("desc.out");

int main()
{
    int n, k, x; in >> n >> k >> x;
    n -= x * ((k * (k - 1)) / 2);
    if(n < 0){
        out << "0\n";
        return 0;
    }
    
    n -= k; // sa nu fie niciunul nul
    
    //cout << "n = " << n << '\n';
    
    dp[0][0] = 1;
    for(int s = 0; s <= n; s++){
        for(int j = 0; j < k; j++){
            if(dp[s][j] == 0) continue;
            for(int add = 0; s + add * (k - j) <= n; add++){
                dp[s + add * (k - j)][j + 1] += dp[s][j];
                dp[s + add * (k - j)][j + 1] %= MOD;
            }
        }
    }

    out << dp[n][k] << '\n';

    return 0;
}