-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoring_Appartments.cpp
More file actions
38 lines (31 loc) · 841 Bytes
/
Boring_Appartments.cpp
File metadata and controls
38 lines (31 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// we call appartment boring if it has same numbers like 11,222,1111
// there are 1 to 10000 buildings
// count keypress
#include <bits/stdc++.h>
using namespace std;
int digits_count(int n){
if (n == 1) return 1;
else if (n == 2) return 3;
else if (n == 3) return 6;
else if (n == 4) return 10;
}
int main()
{
int testcases = 0;
cin >> testcases;
for(int i = 0; i < testcases; i++){
int answerer = 0;
cin >> answerer;
int consits_of = 0;
int digits = 0;
while(answerer > 0){
consits_of = answerer % 10;
digits++;
answerer /= 10;
}
// in each time he has 1 + 11 + 111 + 1111 = 10 presses
int answer = 0;
answer = (consits_of - 1) * 10 + digits_count(digits);
cout << answer << endl;
}
}