-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1157A.cpp
More file actions
57 lines (50 loc) · 1.47 KB
/
Copy path1157A.cpp
File metadata and controls
57 lines (50 loc) · 1.47 KB
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
// Created on 28-Sep-25
// done
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define faster \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define getUnique(v) \
{ \
sort(v.begin(), v.end()); \
v.erase(unique(v.begin(), v.end()), v.end()); \
}
#define nl '\n'
int main() {
faster;
int n;
cin >> n;
int len = log10(n);
int first = (int) n / pow(10, len);
// base logic
// put the unique nums in a set until it reaches its first number twice
set<int> s;
s.insert(first);
s.insert(n);
n++;
int c = 0;
// cout<<"zfb"<<n<<nl;
while (true) {
if (n == first)
c++;
if (c > 1)
break;
if (n % 10 != 0) {
s.insert(n);
// cout << n << " ";
n++;
} else {
while (n % 10 == 0) {
n /= 10;
}
}
}
// s.insert(n);
// cout << nl << nl;
cout << s.size();
return 0;
}