Cod sursa(job #2618834)

Utilizator PatrickCplusplusPatrick Kristian Ondreovici PatrickCplusplus Data 26 mai 2020 13:28:07
Problema Diviz Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.84 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("diviz.in");
ofstream fout("diviz.out");

const int nmax = 200, mod = 30103;
int k, a, b, n, v[nmax + 5], dp[11][nmax + 3][103], pos[10][nmax + 3], aux[nmax + 5][nmax + 5];
char ch;

int main()
{
    fin >> k >> a >> b;
    while (fin >> ch) v[++n] = ch - '0';
    for (int index = n; index >= 1; --index)
    {
        for (int nr = k - 1; nr >= 0; --nr)
        {
            for (int cif = n; cif >= 1; --cif)
            {
                if (v[index] == 0 && cif == 1) continue;
                int new_nr = (nr * 10 + v[index]) % k;
                for (int c = 0; c <= 9; ++c)
                    aux[cif][nr] = (1LL * aux[cif][nr] + dp[c][cif + 1][new_nr]) % mod;
            }
        }
    }
    fout << 4;
    fin.close();
    fout.close();
    return 0;
}