Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){

  ll l,a,b,m;
  cin>>l>>a>>b>>m;
  ll modM[19];
  REP(i,19){
    ll t = modpow(10,i);
    modM = t;
  }
  ll keta[19];
  int maxKeta = 18;
  keta[0] = -1;
  for(int i=1;i<19;i++){
    keta[i] = (modpow(10,i)-1 - a) / b;
    keta[i] = max(-1,keta[i]);
    if(keta[i]>=l){
      keta[i] = l;
      maxKeta = i;
    }
  }

  ll ans = 0;
  //Aの方を処理
  for(int i=1;i<=maxKeta;i++){
    if(keta[i]<0)break;
    int len = keta[i] - keta[i-1];
    ll r = modpow(10,i);
    ans += (a * modpow(r,len)-1) * (modinv(r-1));
    ans %= MOD;
    if(i!=maxKeta)ans *= r;
    ans %= MOD;
  }

  ll ans2 = 0;
  //Bどうするの？？？？？
  for(int i=1;<maxKeta;i++){
    if(keta[i]<0)break;
    int len = keta[i] = keta[i-1];
    ll r = modpow(10,i);
    ll x;
    ll p,q;
    p = keta[i-1]+1;
    q = keta[i];
    ll invR = modinv(r,MOD);
    x = b*(p-1) *  modpow(10,i*(len-1)) - b*q * invR + (b * modpow(r,len)-1 * (modinv(r-1)));
    x = x * modinv(1 - invR);
    ans += x;
    ans %= MOD;
    if(i!=maxKeta)ans *= r;
    ans %= MOD;
  }




 

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:10: error: incompatible types in assignment of 'long long int' to 'long long int [19]'
   56 |     modM = t;
      |     ~~~~~^~~
a.cc:63:18: error: no matching function for call to 'max(int, long long int&)'
   63 |     keta[i] = max(-1,keta[i]);
      |               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:63:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   63 |     keta[i] = max(-1,keta[i]);
      |               ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:63:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   63 |     keta[i] = max(-1,keta[i]);
      |               ~~~^~~~~~~~~~~~
a.cc:76:43: error: too few arguments to function 'long long int modinv(long long int, long long int)'
   76 |     ans += (a * modpow(r,len)-1) * (modinv(r-1));
      |                                     ~~~~~~^~~~~
a.cc:37:11: note: declared here
   37 | long long modinv(long long a, long long m) {
      |           ^~~~~~
a.cc:84:15: error: expected primary-expression before '<' token
   84 |   for(int i=1;<maxKeta;i++){
      |               ^
a.cc:93:86: error: too few arguments to function 'long long int modinv(long long int, long long int)'
   93 |     x = b*(p-1) *  modpow(10,i*(len-1)) - b*q * invR + (b * modpow(r,len)-1 * (modinv(r-1)));
      |                                                                                ~~~~~~^~~~~
a.cc:37:11: note: declared here
   37 | long long modinv(long long a, long long m) {
      |           ^~~~~~
a.cc:94:19: error: too few arguments to function 'long long int modinv(long long int, long long int)'
   94 |     x = x * modinv(1 - invR);
      |             ~~~~~~^~~~~~~~~~
a.cc:37:11: note: declared here
   37 | long long modinv(long long a, long long m) {
      |           ^~~~~~