fork download
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<vector>
  4. #include<cmath>
  5. #include<climits>
  6. using namespace std;
  7. int main(){
  8.  
  9. long long n;
  10. cin>>n;
  11. long long x=n;
  12. long long count=0;
  13. while(x>0){
  14.  
  15. count++;
  16. x/=10;
  17. }
  18. long long ans=0;
  19. ans=(n-pow(10,count-1)+1)*count;
  20. for(long long i=count-2;i>=0;i--){
  21.  
  22. ans+=9*pow(10,i)*(i+1);
  23. }
  24. cout<<ans<<endl;
  25. }
Success #stdin #stdout 0s 2732KB
stdin
1000000000
stdout
8888888899