题目描述
题目链接
C++代码
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const int mod = 998244353;
LL Pow(LL n, int k){
LL res = 1;
while(k){
if(k & 1) res *= n;
k >>= 1;
n *= n;
}
return res;
}
void solve(LL n){
string s = to_string(n);
int len = s.size();
LL res = 0;
for(int i = 1; i <= len - 1; i ++){
LL ed = 9 * Pow(10, i - 1);
res = (LL)(res + (LL)(1 + ed) % mod * (ed % mod) / 2) % mod;
}
LL x = Pow(10, len - 1);
LL ed = n - x + 1;
res = (LL)(res + (LL)(1 + ed) % mod * (ed % mod) / 2) % mod;
cout << res << '\n';
return ;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
LL n;
cin >> n;
solve(n);
return 0;
}