#include <iostream>
using namespace std;
int units[10] = {0, 3, 3, 5, 4, 4, 3, 5, 5, 4};
int teens[10] = {3, 6, 6, 8, 8, 7, 7, 9, 8, 8};
int tens[8] = {6, 6, 5, 5, 5, 7, 6, 6};
int hundred = 10;
int thousand = 11;
unsigned int counter;
int main()
{
//1-9
for(int i=1; i<10; i++)
counter = counter + units[i];
//10-19
for(int i=0; i<10; i++)
counter = counter + teens[i];
//20-99
for(int i=0; i<8; i++)
for(int j=0; j<10; j++)
counter = counter + tens[i] + units[j];
//100-999
for(int i=1; i<10; i++) //1xx-9xx
{
counter = counter + units[i] + 7; //100, 200, 300...
for(int j=1; j<10; j++)
counter = counter + units[i] + hundred + units[j]; //x01-x09
for(int j=0; j<10; j++)
counter = counter + units[i] + hundred + teens[j]; //x10-x19
for(int j=0; j<8; j++)
for(int k=0; k<10; k++)
counter = counter + units[i] + hundred + tens[j] + units[k]; //x20-x99 -
}
counter += thousand; // +1000
cout << counter << endl;
return 0;
}
Darmowy hosting zapewnia PRV.PL