Created
September 2, 2019 08:33
-
-
Save surinoel/2954e03847792090361dd4e675117d05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <string> | |
#include <iostream> | |
using namespace std; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int n; | |
cin >> n; | |
string s = to_string(n); | |
int len = s.size(); | |
int ans = 0; | |
ans = len * (n - (int)pow(10, len - 1) + 1); | |
for (int i = len - 1; i >= 1; i--) { | |
ans += 9 * (int)pow(10, i - 1) * i; | |
} | |
cout << ans << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment