-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCF659ARoundHouse.java
More file actions
44 lines (38 loc) · 1.02 KB
/
CF659ARoundHouse.java
File metadata and controls
44 lines (38 loc) · 1.02 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
/**
* See
* <a href="http://codeforces.com/problemset/problem/659/A">Round House</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class CF659ARoundHouse {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
int[] p = readArray();
int n = p[0];
int a = p[1];
int b = p[2];
int moves = b % n;
int pos;
if (moves == 0) {
out.print(a);
} else if (moves > 0) {
pos = a + moves;
out.print(pos > n ? pos - n: pos);
} else if (moves < 0) {
pos = a + moves;
out.print(pos <= 0 ? n + pos : pos);
}
out.close();
}
private static int[] readArray() throws IOException {
String[] line = in.readLine().split("\\s");
int[] a = Arrays.stream(line).mapToInt(Integer::parseInt).toArray();
return a;
}
}