Skip to content

Instantly share code, notes, and snippets.

@Transfusion
Created December 7, 2019 17:14
Show Gist options
  • Select an option

  • Save Transfusion/97f3eeda745bebad73c96e6f05eb5e92 to your computer and use it in GitHub Desktop.

Select an option

Save Transfusion/97f3eeda745bebad73c96e6f05eb5e92 to your computer and use it in GitHub Desktop.
CodeForces 399A
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(f.readLine());
int n = Integer.parseInt(st.nextToken());
int p = Integer.parseInt(st.nextToken());
int k = Integer.parseInt(st.nextToken());
if (p - k <= 1) {
} else {
System.out.print("<< ");
}
for (int i = Math.max(1, p - k); i < p; i++){
System.out.print(String.valueOf(i) + " ");
}
System.out.print("(" + String.valueOf(p) + ")");
for (int i = p + 1; i < Math.min(n + 1, p + k + 1); i++) {
System.out.print(" " + String.valueOf(i));
}
if (p + k < n) {
System.out.print(" >>");
}
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment