-
Notifications
You must be signed in to change notification settings - Fork 0
/
CF271A.java
34 lines (32 loc) · 908 Bytes
/
CF271A.java
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
import java.util.HashSet;
import java.util.Scanner;
public class CF271A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
while(true) {
year++;
HashSet<Integer> set = new HashSet<>();
int temp = year;
boolean flag = true;
while(temp > 0) {
if(set.isEmpty()) {
set.add(temp%10);
} else {
if(set.contains(temp%10)){
flag = false;
break;
} else {
set.add(temp%10);
}
}
temp = temp/10;
}
if(flag == true) {
System.out.println(year);
break;
}
}
sc.close();
}
}