Vanya and Books - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
ac代码
#include<bits/stdc++.h>
typedef long long ll;#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const ll N=1e3;
using namespace std;int main()
{IOS;ll x;cin>>x;ll ans=0,p=x;int k2=0,k=0;while(x){k++;x/=10;}k2=k;ll a=pow(10,k-1);if(k2==k) ans+=k*(p-a+1);//cout<<ans<<endl;for(int i=1;i<k;i++){ans+=i*9*pow(10,i-1);//cout<<ans<<endl;}cout<<ans<<endl;return 0;
}