-
Notifications
You must be signed in to change notification settings - Fork 0
/
1433A-Boring Apartments.cpp
64 lines (60 loc) · 1.26 KB
/
1433A-Boring Apartments.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//https://codeforces.com/problemset/problem/1433/A
//Boring Apartments
#include <bits/stdc++.h>
using namespace std;
void solve(){
long long n;
cin>>n;
vector<int>v;
v.push_back(1);
v.push_back(11);
v.push_back(111);
v.push_back(1111);
for(int i=2;i<10;i++){
for(int j=0;j<4;j++){
int d=v[j]*i;
v.push_back(d);
}
}
int c = 0;
for(int i=0;i<v.size();i++){
if(v[i]==n){
if(v[i]<10){
c++;
}
else if(v[i]<100){
c+=2;
}
else if(v[i]<1000){
c+=3;
}
else if(v[i]<10000){
c+=4;
}
break;
}
if(v[i]<10){
c++;
}
else if(v[i]<100){
c+=2;
}
else if(v[i]<1000){
c+=3;
}
else if(v[i]<10000){
c+=4;
}
}
cout<<c<<endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
long long t;
cin>>t;
while(t--)
solve();
return 0;
}