Language: C++

#include <bits/stdc++.h>

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(bool a) {
  return a ? "T" : "F";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;

const int N = 1e7, B = 1e9 + 7;

int sum[N];
int dig[N];

int calc(int i) {
  if (i < 10) return 1;
  if (i < 100) return 2;
  if (i < 1000) return 3;
  if (i < 10000) return 4;
  if (i < 100000) return 5;
  if (i < 1000000) return 6;
  return 7;
}

void init() {
  int od = 1;
  for (int i = 1; i < N; ++i) {
    dig[i] = calc(i);
  }
  for (int i = 1; i < N; ++i) {
    sum[i] = sum[i - 1] + dig[i];
  }
}

void add(ll &x, int y) {
  x = (x + y) % B;
  if (x < 0) x += B;
}

void run() {
  ll ans = 0;
  init();
  cin >> S;
  for (int i = 0; i < N; ++i) {
    int t = *lower_bound(sum, sum + N, S + sum[i]);
    if (t == S + sum[i]) ++ans;
  }
  int ts = S - sum[N - 1] - sum[int(1e6 - 1)];
  int d = floor(ts, 8) * 8 - ts;
  if (d % 2 == 0) {
    d /= 2;
    int c8 = floor(ts, 8) - d;
    //huan 3 ci
    add(ans, floor(c8, 3));
  }
  for (int s = 7; s < S; ++s) {
    int d = floor(S, s + 1) * (s + 1) - S;
    int ce = floor(S, s + 1) - d;
    add(ans, floor(ce, s));
  }
  cout << ans << endl;
}

int main() {
  run();
  return 0;
}


Compiler output:
a.cc: In function 'void run()':
a.cc:90:10: error: 'S' was not declared in this scope
   90 |   cin >> S;
      |          ^
a.cc:96:16: error: no matching function for call to 'floor(int&, int)'
   96 |   int d = floor(ts, 8) * 8 - ts;
      |           ~~~~~^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:114,
                 from a.cc:1:
/usr/include/c++/14/cmath:269:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::floor(_Tp)'
  269 |     floor(_Tp __x)
      |     ^~~~~
/usr/include/c++/14/cmath:269:5: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note: candidate: 'double floor(double)'
  198 | __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
      | ^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:261:3: note: candidate: 'constexpr long double std::floor(long double)'
  261 |   floor(long double __x)
      |   ^~~~~
/usr/include/c++/14/cmath:261:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:257:3: note: candidate: 'constexpr float std::floor(float)'
  257 |   floor(float __x)
      |   ^~~~~
/usr/include/c++/14/cmath:257:3: note:   candidate expects 1 argument, 2 provided
a.cc:99:19: error: no matching function for call to 'floor(int&, int)'
   99 |     int c8 = floor(ts, 8) - d;
      |              ~~~~~^~~~~~~
/usr/include/c++/14/cmath:269:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::floor(_Tp)'
  269 |     floor(_Tp __x)
      |     ^~~~~
/usr/include/c++/14/cmath:269:5: note:   candidate expects 1 argument, 2 provided
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note: candidate: 'double floor(double)'
  198 | __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
      | ^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:261:3: note: candidate: 'constexpr long double std::floor(long double)'
  261 |   floor(long double __x)
      |   ^~~~~
/usr/include/c++/14/cmath:261:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:257:3: note: candidate: 'constexpr float std::floor(float)'
  257 |   floor(float __x)
      |   ^~~~~
/usr/include/c++/14/cmath:257:3: note:   candidate expects 1 argument, 2 provided
a.cc:101:19: error: no matching function for call to 'floor(int&, int)'
  101 |     add(ans, floor(c8, 3));
      |              ~~~~~^~~~~~~
/usr/include/c++/14/cmath:269:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::floor(_Tp)'
  269 |     floor(_Tp __x)
      |     ^~~~~
/usr/include/c++/14/cmath:269:5: note:   candidate expects 1 argument, 2 provided
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note: candidate: 'double floor(double)'
  198 | __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
      | ^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:261:3: note: candidate: 'constexpr long double std::floor(long double)'
  261 |   floor(long double __x)
      |   ^~~~~
/usr/include/c++/14/cmath:261:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:257:3: note: candidate: 'constexpr float std::floor(float)'
  257 |   floor(float __x)
      |   ^~~~~
/usr/include/c++/14/cmath:257:3: note:   candidate expects 1 argument, 2 provided
a.cc:106:19: error: no matching function for call to 'floor(int&, int&)'
  106 |     add(ans, floor(ce, s));
      |              ~~~~~^~~~~~~
/usr/include/c++/14/cmath:269:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::floor(_Tp)'
  269 |     floor(_Tp __x)
      |     ^~~~~
/usr/include/c++/14/cmath:269:5: note:   candidate expects 1 argument, 2 provided
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note: candidate: 'double floor(double)'
  198 | __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
      | ^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:198:1: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:261:3: note: candidate: 'constexpr long double std::floor(long double)'
  261 |   floor(long double __x)
      |   ^~~~~
/usr/include/c++/14/cmath:261:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:257:3: note: candidate: 'constexpr float std::floor(float)'
  257 |   floor(float __x)
      |   ^~~~~
/usr/include/c++/14/cmath:257:3: note:   candidate expects 1 argument, 2 provided