반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <iostream> using namespace std; int n, i, ans; int pow(int x, int n) { if (n == 0) return 1; return x * pow(x, n - 1); } int main() { cin >> n; i = 1; while (n >= pow(10, i)) { ans += 9 * pow(10, i - 1) * i; i++; } ans += (n - pow(10, i - 1) + 1) * i; cout << ans; } | cs |
반응형