L1-071 前世档案(java)

import java.util.Scanner;

public class Artive {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String msg = scanner.nextLine();
        int zhishu = Integer.parseInt(msg.split(" ")[0]);
        int line_num = Integer.parseInt(msg.split(" ")[1]);
        for(int i = 0; i < line_num; i++) {
            String answer = scanner.nextLine();
            int sum = 0;
            for (int j = 0; j < answer.length(); j++) {
                char c = answer.charAt(j);
                if(c == 'y'){
                    int num = (int)Math.pow(2,zhishu-j-1);
                    sum+=num;
                }
            }
            System.out.println((int)Math.pow(2,zhishu)-sum);
        }
    }
}