fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define lli long long int
  4. const int MAX=1e9+7;
  5. #define EPS 1e-9
  6. lli solve(lli n){
  7. lli sz=log10(n)+EPS+1;
  8. if(sz==1)return n;
  9. lli ans=9+(n-pow(10,sz-1)+EPS+1)*sz;
  10. for(int i=sz-1;i>1;i--){
  11. ans+=9*i*(pow(10,i-1)+EPS);
  12. }
  13. return ans;
  14. }
  15. int main()
  16. {
  17.  
  18. lli n;
  19. cin>>n;
  20. cout<<solve(n)<<"\n";
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3144KB
stdin
1000000000
stdout
8888888899