-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunround.java
More file actions
56 lines (50 loc) · 1.22 KB
/
Copy pathrunround.java
File metadata and controls
56 lines (50 loc) · 1.22 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
/*
ID: 001207j1
LANG: JAVA
TASK: runround
*/
import java.io.*;
import java.util.*;
public class runround {
public static void main(String[] args) throws IOException {
runround m = new runround();
m.run();
}
public static void run() throws IOException {
long start_Time = System.currentTimeMillis();
BufferedReader f = new BufferedReader(new FileReader("runround.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("runround.out")));
int n = Integer.parseInt(f.readLine());
for (n++; !isRunRound(n); n++)
;
out.println(n);
f.close();
out.close();
System.out.println(System.currentTimeMillis() - start_Time);
}
public static boolean isRunRound(int n) {
String t = Integer.toString(n);
if (!check(t))
return false;
boolean[] mark = new boolean[t.length()];
int i = 0;
for (int ct = 0; ct < t.length(); ct++) {
i = (i + t.charAt(i) - '0') % t.length();
if (!mark[i]) {
mark[i] = true;
} else
return false;
}
return true;
}
public static boolean check(String t) {
boolean[] check = new boolean[10];
for (int i = 0; i < t.length(); i++) {
if (check[t.charAt(i) - '0'])
return false;
else
check[t.charAt(i) - '0'] = true;
}
return true;
}
}