Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll L,A,B,M;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
mint pow_(mint x, ll t) {
  if (t == 0) return 1;
  if (t%2 == 1) {
    return pow_(x,t-1)*x;
  } else {
    mint y = pow_(x,t/2);
    return y*y;
  }
}
ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
ll S1(ll r, ll T,ll M){
  if(r==1){
    return T%M;
  }
  ll x = pow_(r,T)%(M*(r-1)) -1;
  return (x%(r-1))%M;
}
ll S2(ll r,ll T,ll M){
  if(r==1){
    ll x = T*(T-1);
    return x%M;
  }
  ll Mr = M*(r-1);
  ll x = (T-1) * pow_(r,T)&Mr;
  x -= S1(r,T,Mr);
  x++;
  return x;
}

ll cal(ll L,ll A,ll B,ll M){
  ll result = 0;
  ll d = GetDigit(A);//桁数
  ll start = A;
  ll r = pow_(10,d);
  cout<<start<<" "<<d<<" "<<r <<endl;
  while(1){
    ll n1 = ((r-1)-A);//B+1
    ll items = min(n1,L);//その桁の項数
    ll last = A + (items-1)*B;
    ll x = last * S1(r,items,M);
    ll x -= B*S2(r,items,M);
    result *= pow_(r,items)%M:
    result += x;
    result %= M;
    //パラメータの更新
    r *=10;
    d ++;//不要かも
    L -= items;
    A += B*items;
    if(L<=0){
      break;
      return result%M;
    }
  }
}

int main(){
 cin>>L,A,B,M;
 ll ans = cal(L,A,B,M);
 cout<<pow(10,2)<<endl;
 cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'll S1(ll, ll, ll)':
a.cc:75:19: error: no match for 'operator%' (operand types are 'mint' and 'll' {aka 'long long int'})
   75 |   ll x = pow_(r,T)%(M*(r-1)) -1;
      |          ~~~~~~~~~^~~~~~~~~~
      |              |       |
      |              mint    ll {aka long long int}
a.cc: In function 'll S2(ll, ll, ll)':
a.cc:84:16: error: no match for 'operator*' (operand types are 'll' {aka 'long long int'} and 'mint')
   84 |   ll x = (T-1) * pow_(r,T)&Mr;
      |          ~~~~~ ^ ~~~~~~~~~
      |            |         |
      |            |         mint
      |            ll {aka long long int}
a.cc: In function 'll cal(ll, ll, ll, ll)':
a.cc:94:14: error: cannot convert 'mint' to 'll' {aka 'long long int'} in initialization
   94 |   ll r = pow_(10,d);
      |          ~~~~^~~~~~
      |              |
      |              mint
a.cc:101:10: error: expected initializer before '-=' token
  101 |     ll x -= B*S2(r,items,M);
      |          ^~
a.cc:102:30: error: found ':' in nested-name-specifier, expected '::'
  102 |     result *= pow_(r,items)%M:
      |                              ^
      |                              ::
a.cc:102:29: error: 'M' is not a class, namespace, or enumeration
  102 |     result *= pow_(r,items)%M:
      |                             ^
a.cc:111:7: warning: control reaches end of non-void function [-Wreturn-type]
  111 |       break;
      |       ^~~~~