第一题AC了,第二题不会做 
 import java.util.*;
public class NO1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        Map<String,Integer> map = new HashMap<>();
        map.put("()", 1);
        int result = helper(s,map);
        System.out.println(result);
    }
    public static int helper(String s , Map<String,Integer> map){
        if(map.containsKey(s)){
            return map.get(s);
        }
        int count = 0;
		int result = 0;
        for(int i = 0 ; i < s.length(); i ++){
        	if(s.charAt(i) == '('){
        		count++;
        	}else{
        		count--;
        	}
            if(count >= 0 && s.charAt(i) == ')'){
            	String left = s.substring(1,i);
            	String right = s.substring(i+1,s.length());
                result+= helper(left+right,map);
            }
        }
        map.put(s,result);
        return result;
    }
}