Last active
August 29, 2015 14:19
-
-
Save rogerioagjr/740e226db173e746d035 to your computer and use it in GitHub Desktop.
Contando estrelas - Roger Benet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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