#ifdef MAIN ================================================================================================================================ +library{ name:mint, url:"https://tqkoh.github.io/library/library/lib/util/mint.hpp", version:"2020-08-08" } int solve(){ lin(N); cs s(N,'9'); lint n=s.size(); vector>dp0(n+10,vector(10)),dp1(n+10,vector(10)); dp0[0][0] = 1; rep(n){ rep(j,10){ rep(l,j,10)dp1[i+1][l] += dp1[i][j]; rep(l,j,s[i]-'0')dp1[i+1][l] += dp0[i][j]; lint l = s[i]-'0'; if(j<=l)dp0[i+1][l] += dp0[i][j]; } } mint ans=0; rep(j,10)ans+=dp0[n][j]+dp1[n][j]; out(ans); return 0; } #endif MAIN ================================================================================================================================ //sub-BOF // desktop // author: Tqk //#define _AOJ_ #define _C_INPUT_ // #pragma region template // #pragma region basic #define IN_FILE "./in.txt" //#pragma GCC optimize ("O3") #pragma warning(disable: 4455 4244 4067 4068 4996) #pragma GCC target ("avx") #pragma GCC diagnostic ignored "-Wliteral-suffix" #define NOMINMAX #ifdef _ENV_TQK_ #include #endif #include "bits/stdc++.h" using namespace std; typedef int64_t lint; typedef long double ld; typedef string cs; #define linf 1152921504606846976 #ifndef _AOJ_ inline lint operator""z(const unsigned long long n){ return lint(n); } #endif templateinline T operator-(const vector& a,const size_t&i){return a.at(i);} // #pragma endregion // #pragma region rep #define _vcppunko3(tuple) _getname3 tuple #define _vcppunko4(tuple) _getname4 tuple #define _getname4(_1,_2,_3,_4,name,...) name #define _getname3(_1,_2,_3,name,...) name #define _trep2(tuple) _rep2 tuple #define _trep3(tuple) _rep3 tuple #define _trep4(tuple) _rep4 tuple #define _rep1(n) for(lint i=0;i=0;--i) #define _per2(i,n) for(lint i=n-1;i>=0;--i) #define _per3(i,a,b) for(lint i=b-1;i>=a;--i) #define _per4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c) #define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__)) #define per(...) _vcppunko4((__VA_ARGS__,_tper4,_tper3,_tper2,_per1))((__VA_ARGS__)) #define _tall2(tuple) _all2 tuple #define _tall3(tuple) _all3 tuple #define _all1(v) v.begin(),v.end() #define _all2(v,a) v.begin(),v.begin()+a #define _all3(v,a,b) v.begin()+a,v.begin+b #define all(...) _vcppunko3((__VA_ARGS__,_tall3,_tall2,_all1))((__VA_ARGS__)) #define each(c) for(auto &e:c) // #pragma endregion // #pragma region io template istream& operator>>(istream& is,vector& vec); template istream& operator>>(istream& is,array& vec); template istream& operator>>(istream& is,pair& p); template ostream& operator<<(ostream& os,vector& vec); template ostream& operator<<(ostream& os,pair& p); template istream& operator>>(istream& is,vector& vec){ for(T& x: vec) is>>x;return is; } template istream& operator>>(istream& is,pair& p){ is>>p.first;is>>p.second;return is; } template ostream& operator<<(ostream& os,pair& p){ os< ostream& operator<<(ostream& os,vector& vec){ os< ostream& operator<<(ostream& os,deque& deq){ os< ostream& operator<<(ostream& os,set& s){ each(s)os< ifstream& operator>>(ifstream& is,vector& vec); template ifstream& operator>>(ifstream& is,array& vec); template ifstream& operator>>(ifstream& is,pair& p); template ifstream& operator>>(ifstream& is,vector& vec){ for(T& x: vec) is>>x;return is; } template ifstream& operator>>(ifstream& is,pair& p){ is>>p.first;is>>p.second;return is; } inline void fin(){} template inline void fin(Head&& head,Tail&&... tail){ infile>>head;fin(move(tail)...); } */ //#include HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); inline void in(){ SetConsoleTextAttribute(hConsole,10); } template inline void in(Head&& head,Tail&&... tail){ SetConsoleTextAttribute(hConsole,15); cin>>head;in(move(tail)...); } #else inline void in(){} template inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); } #endif inline bool out(){ return(cout<<'\n',0); } template inline bool out(T t){ return(cout< inline bool out(Head head,Tail... tail){ cout< inline void alloc(T &c,lint s){ rep(c.size())c[i].resize(s); } #define alc alloc #ifdef _ENV_TQK_ inline bool deb(){ SetConsoleTextAttribute(hConsole,10); return(cout<<'\n',0); } template inline bool deb(T t){ return(SetConsoleTextAttribute(hConsole,12),cout< inline bool deb(Head head,Tail... tail){ SetConsoleTextAttribute(hConsole,12); cout< name(size);in(name) #define pb push_back #define fi e.first #define se e.second #define YES(c) cout<<((c)?"YES\n":"NO\n"),0 #define Yes(c) cout<<((c)?"Yes\n":"No\n"),0 #define POSSIBLE(c) cout<<((c)?"POSSIBLE\n":"IMPOSSIBLE\n"),0 #define Possible(c) cout<<((c)?"Possible\n":"Impossible\n"),0 #define o(p) cout<r)swap(l,r); #define fn(ty1,ty2,ex) [&](ty1 l,ty2 r){ return(ex); } #define lfn(ex) [&](lint l,lint r){ return(ex); } // #pragma endregion // #pragma region func inline constexpr lint gcd(lint a,lint b){ while(b){ lint c=b;b=a%b;a=c; }return a; } inline constexpr lint lcm(lint a,lint b){ return a/gcd(a,b)*b; } template inline constexpr bool chmin(T &mn,const T &cnt){ if(mn>cnt){ mn=cnt;return 1; } else return 0; } template inline constexpr bool chmax(T &mx,const T &cnt){ if(mx>(istream& os,P& p){ os>>p.f>>p.s;return os; } inline constexpr bool operator<(const P& l,const P& r){ return(l.f-r.f?l.f(const P& l,const P& r){ return(l.f-r.f?l.f>r.f:l.s>r.s); } inline constexpr bool operator==(const P& l,const P& r){ return(l.f==r.f&&l.s==r.s); } inline constexpr bool operator!=(const P& l,const P& r){ return(l.f!=r.f||l.s!=r.s); } inline P operator+(const P& l,const P& r){return P(l.f+r.f,l.s+r.s);} inline P operator-(const P& l,const P& r){return P(l.f-r.f,l.s-r.s);} inline P operator-(const P& r){return P(-r.f,-r.s); } inline P operator*(const lint& l,const P& r){return P(l*r.f,l*r.s); } inline P operator/(const P& l,const lint& r){return P(l.f/r,l.s/r); } inline ld abs(P p){return sqrtl(p.f*p.f+p.s*p.s);} inline ld mabs(P p){return abs(p.f)+abs(p.s);} inline ld mht(P x,P y){return mabs(x-y);} // #pragma endregion // #pragma region start struct Start{ Start(){ #ifndef _C_INPUT_ cin.tie(0),cout.tie(0); ios::sync_with_stdio(0); #endif cout< md_tmp class modint{ using u64 = uint_fast64_t; public: u64 a; constexpr modint(const lint x = 0) noexcept: a((x+md)%md){} constexpr u64& value() noexcept{ return a; } constexpr const u64& value() const noexcept{ return a; } constexpr modint operator+(const modint rhs) const noexcept{ return modint(*this) += rhs; } constexpr modint operator-(const modint rhs) const noexcept{ return modint(*this) -= rhs; } constexpr modint operator*(const modint rhs) const noexcept{ return modint(*this) *= rhs; } constexpr modint operator^(const lint rhs) const noexcept{ return modint(*this) ^= rhs; } constexpr modint operator/(const modint rhs) const noexcept{ return modint(*this) /= rhs; } constexpr modint& operator+=(const modint rhs) noexcept{ a += rhs.a; if(a>=md)a -= md; return *this; } constexpr modint& operator-=(const modint rhs) noexcept{ if(a>= 1; } return *this; } constexpr modint& operator/=(const modint rhs) noexcept{ a = (*this*(rhs^(md-2))).a; return *this; } }; md_tmp istream& operator>>(istream& os,modint& m){ os>>m.a,m.a %= md; return os; } md_tmp ostream& operator<<(ostream& os,const modint& m){ return os<; #ifndef _AOJ_ mint operator""m(unsigned long long n){ return mint(n); } #endif /* * @title Mint * @see https://noshi91.hatenablog.com/entry/2019/03/31/174006 */ // #pragma endregion int solve(){ lin(N); cs s(N,'9'); lint n=s.size(); vector>dp0(n+10,vector(10)),dp1(n+10,vector(10)); dp0[0][0] = 1; rep(n){ rep(j,10){ rep(l,j,10)dp1[i+1][l] += dp1[i][j]; rep(l,j,s[i]-'0')dp1[i+1][l] += dp0[i][j]; lint l = s[i]-'0'; if(j<=l)dp0[i+1][l] += dp0[i][j]; } } mint ans=0; rep(j,10)ans+=dp0[n][j]+dp1[n][j]; out(ans); return 0; } // #pragma endregion // #pragma region main int main(){ solve(); } // #pragma endregion //sub-EOF