Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /**
- *
- * @author Usuario
- */
- public class Aer169 {
- Scanner in = new Scanner (System.in);
- public boolean caso(){
- boolean centinela;
- String apellido;
- String nombre;
- String minus;
- int numeroParticipantes = 0;
- int contador = 0;
- HashMap<String, Integer> participantes = new HashMap<>();
- do{
- apellido = in.next();
- centinela = apellido.equals("====");
- if(!centinela){
- numeroParticipantes++;
- nombre = in.next();
- minus = apellido.toLowerCase();
- if(participantes.containsKey(minus)){
- participantes.put(minus, participantes.get(minus)+1);
- contador = participantes.get(minus)+1;
- }else{
- participantes.put(minus, contador);
- }
- }
- }while(!centinela);
- System.out.format("%d %d%n",numeroParticipantes, contador);
- return true;
- }
- public void run(){
- int numCaso = Integer.parseInt(in.nextLine());
- for(int i = 0; i < numCaso; i++){
- caso();
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- new Aer169().run();
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement