Skip to content

Instantly share code, notes, and snippets.

@rogerioagjr
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerioagjr/740e226db173e746d035 to your computer and use it in GitHub Desktop.
Save rogerioagjr/740e226db173e746d035 to your computer and use it in GitHub Desktop.
Contando estrelas - Roger Benet
import java.io.*;
public class Main {
public static void main(String[] args)throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int[] vet = new int[11000];
int n,r,i,k;
boolean ok;
String w;
String[] aux;
while((w = in.readLine()) != null){
aux = w.split(" ");
n = Integer.parseInt(aux[0]);
r = Integer.parseInt(aux[1]);
aux = in.readLine().split(" ");
for(i = 0; i < r; i++){
k = Integer.parseInt(aux[i]);
vet[k] = 1;
}
ok = true;
for(i = 1; i <= n; i++){
if(vet[i] == 0){
sb.append(i).append(" ");
ok = false;
}
}
if(ok == false){
System.out.println(sb.toString());
}
else {
System.out.println("*");
}
sb.delete(0,sb.length());
for(i = 1; i <= n; i++)
vet[i] = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment