Cod sursa(job #3212678)

Utilizator PiciuAndreiAlinPiciu Andrei Alin PiciuAndreiAlin Data 12 martie 2024 08:42:00
Problema Algoritmul lui Dijkstra Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.7 kb
#include <bits/stdc++.h>

using namespace std;

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

char s[100005];
long long dp[105];

/**
7 3 7
1 1 3
1 2
2 6
1 3 5
1 1 3
2 3
*/

void Citire()
{
    cin>> s;
}

void Rezolvare()
{
    int nr = 0;
    dp[0] = 1;
    for(int i = 0; s[i] != '\0'; i++)
    {
        nr = (int)(s[i] - '0');
        ///if(nr == 9 && dp[9] != 0) dp[9]++;
        for(int j = 9; j >= nr; j--)
            if(dp[j - nr] != 0) dp[j]++;
    }
    cout << dp[9] << "\n";
}

int main()
{
    ios_base :: sync_with_stdio(0);
    fin.tie(0);
    fout.tie(0);
    Citire();
    Rezolvare();
    fin.close();
    fout.close();
    return 0;
}