Editorial for Bedao Grand Contest 04 - REFI


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Code mẫu

#include <bits/stdc++.h>
using namespace std;
#define tag "REFI"
#define maxn 100007
#define oo 1000000007
#define meset(a,x) memset(a,x,sizeof(a))
#define checkfile(FiLeNaMe) { if(fopen(FiLeNaMe".inp","r")) freopen(FiLeNaMe".inp","r",stdin),freopen(FiLeNaMe".out","w",stdout); }
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define base 17
#define MOD 998244353
int n;
int main()
{
    checkfile(tag);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string s;
    cin>>s;
    n=s.size();

    int f[base],g[base];

    meset(f,0);
    f[0]=1;
    for(const char &c: s)
    {
        meset(g,0);

        for(int i=0;i<10;i++)
        {
            if(c!='?' && c!='0'+i) continue;

            for(int k=0;k<base;k++)
                (g[(k*10+i)%base]+=f[k])%=MOD;
        }
        swap(f,g);
    }

    cout<<f[5];
    return 0;
}

Comments

Please read the guidelines before commenting.


There are no comments at the moment.