class Solution {public:int countDigitOne(int n) {int count = 0;int high, low;long long digit;high = n;low = 0;digit = 1;while (high > 0) {int i = high % 10;high /= 10;count += (high * digit);if (i > 1)count += digit;else if (i == 1)count += (low + 1);digit *= 10;low = n % digit;}return count;}};
