-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem_271A.cpp
More file actions
50 lines (38 loc) · 749 Bytes
/
Problem_271A.cpp
File metadata and controls
50 lines (38 loc) · 749 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
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
long long n;
int distinct_count(long long int n){
int arr[10] = {0};
int count = 0;
int i = 0;
while (n)
{
arr[i = n%10] = 1;
n /= 10;
}
for (int j = 0; j < 10; j++)
{
if(arr[j]) count++;
}
return count;
}
int digit_count(long long int n){
int count = 0;
while (n)
{
count++;
n /= 10;
}
return count;
}
int main(){
cin>>n;
while (n < INT_MAX)
{
int get_distinct_count = distinct_count(n+1);
int get_digit_count = digit_count(n+1);
if(get_distinct_count == get_digit_count) {cout<<n+1; break;}
else n++;
}
return 0 ;
}