import java.util.Scanner; import java.util.Arrays; import java.util.HashMap; public class No227 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); HashMap cardMap = new HashMap(); for(int i =0;i < 5;i++){ int card = sc.nextInt(); if(cardMap.containsKey(Integer.toString(card))){ cardMap.put(Integer.toString(card),cardMap.get(Integer.toString(card))+1); }else{ cardMap.put(Integer.toString(card),1); } } sc.close(); No227 obj =new No227(); String hand = obj.judgeHand(cardMap); System.out.println(hand); } private String judgeHand(HashMap cardMap){ String FULL_HOUSE = "FULL HOUSE";//ある数をちょうど3つと、別の数をちょうど2つ含む。 String THREE_CARD = "THREE CARD";//ある数をちょうど3つ含む。 String TWO_PAIR = "TWO PAIR";//ある数をちょうど2つと、別の数をちょうど2つ含む。 String ONE_PAIR = "ONE PAIR";//ある数をちょうど2つ含む。 String NO_HAND = "NO HAND";//上記以外 // for (String key : cardMap.keySet()){ // System.out.println(key + ":" + cardMap.get(key)); // } HashMap handMap =new HashMap(); for (String cardMapKey : cardMap.keySet()){ String handMapKey = Integer.toString(cardMap.get(cardMapKey)); if(cardMap.get(cardMapKey) >= 2){ if (handMap.containsKey(handMapKey)){ handMap.put(handMapKey,handMap.get(handMapKey)+1); }else{ handMap.put(handMapKey,1); } } } if(handMap.size() == 0){ return NO_HAND; }else{ if(handMap.containsKey("3") && handMap.containsKey("2")){ return FULL_HOUSE; }else if(handMap.containsKey("3")){ return THREE_CARD; }else if(handMap.containsKey("2")){ if (handMap.get("2") == 2){ return TWO_PAIR; }else { return ONE_PAIR; } }else{ return NO_HAND; } } } }