4 条题解

  • 0
    @ 2024-1-7 13:29:14
    import java.util.*;
    
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            // 遍历数组a
            for (int i = 0; i < n; i++) {
                String word = sc.next();
                b[i] = word.length();
                // 遍历字符串
                for (int j = 0; j < word.length(); j++) {
                    int c = word.charAt(j) - 'a';
                    a[i] |= 1 << c;
                }
            }
            int num = 0;
            for (int i = 0; i < a.length; i++) {
                for (int j = i; j < a.length; j++) {
                    if ((a[i] & a[j]) == 0) {
                        num = Math.max(num, b[i] * b[j]);
                    }
                }
            }
            System.out.println(num);
        }
    }
    

    信息

    ID
    590
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    (无)
    递交数
    116
    已通过
    34
    上传者