結果

問題 No.462 6日知らずのコンピュータ
ユーザー tentententen
提出日時 2021-11-02 10:40:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,866 bytes
コンパイル時間 2,037 ms
コンパイル使用メモリ 78,204 KB
実行使用メモリ 52,076 KB
最終ジャッジ日時 2024-04-19 16:49:22
合計ジャッジ時間 8,383 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
37,000 KB
testcase_01 AC 48 ms
37,024 KB
testcase_02 AC 48 ms
37,024 KB
testcase_03 AC 49 ms
36,744 KB
testcase_04 AC 49 ms
36,724 KB
testcase_05 AC 48 ms
36,456 KB
testcase_06 WA -
testcase_07 AC 47 ms
36,936 KB
testcase_08 AC 48 ms
36,596 KB
testcase_09 AC 48 ms
36,888 KB
testcase_10 AC 47 ms
36,468 KB
testcase_11 AC 47 ms
36,460 KB
testcase_12 AC 47 ms
36,704 KB
testcase_13 AC 49 ms
36,920 KB
testcase_14 AC 51 ms
36,700 KB
testcase_15 AC 47 ms
36,800 KB
testcase_16 AC 47 ms
36,892 KB
testcase_17 AC 48 ms
36,928 KB
testcase_18 AC 48 ms
36,744 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 48 ms
36,464 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 47 ms
36,900 KB
testcase_50 AC 48 ms
36,932 KB
testcase_51 AC 47 ms
36,928 KB
testcase_52 AC 48 ms
36,892 KB
testcase_53 AC 49 ms
36,752 KB
testcase_54 AC 47 ms
37,064 KB
testcase_55 AC 48 ms
36,796 KB
testcase_56 AC 47 ms
36,972 KB
testcase_57 AC 51 ms
37,152 KB
testcase_58 AC 49 ms
36,800 KB
testcase_59 AC 47 ms
36,924 KB
testcase_60 AC 48 ms
37,028 KB
testcase_61 AC 47 ms
36,800 KB
testcase_62 AC 47 ms
36,864 KB
testcase_63 AC 48 ms
36,720 KB
testcase_64 AC 46 ms
37,020 KB
testcase_65 AC 48 ms
36,444 KB
testcase_66 AC 47 ms
36,780 KB
testcase_67 AC 48 ms
36,704 KB
testcase_68 AC 48 ms
36,896 KB
testcase_69 AC 58 ms
36,596 KB
testcase_70 AC 59 ms
36,892 KB
testcase_71 AC 49 ms
37,040 KB
testcase_72 AC 47 ms
36,780 KB
testcase_73 AC 47 ms
36,976 KB
testcase_74 AC 47 ms
36,984 KB
testcase_75 AC 48 ms
36,592 KB
testcase_76 AC 49 ms
36,984 KB
testcase_77 AC 48 ms
36,692 KB
testcase_78 AC 48 ms
36,768 KB
testcase_79 AC 48 ms
37,040 KB
testcase_80 AC 47 ms
37,004 KB
testcase_81 AC 49 ms
36,456 KB
testcase_82 AC 48 ms
36,464 KB
testcase_83 AC 48 ms
36,452 KB
testcase_84 AC 50 ms
36,968 KB
testcase_85 AC 49 ms
36,708 KB
testcase_86 AC 52 ms
36,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        long current = 0;
        int k = sc.nextInt();
        long ans = 1;
        for (int i = 0; i < k; i++) {
            long x = sc.nextLong();
            if ((current | x) == x) {
                ans *= kaijo(pop(x) - pop(current));
                ans %= MOD;
            } else {
                ans = 0;
            }
            current = x;
        }
        long last = (1L << n) - 1;
        if ((current | last) == last) {
            ans *= kaijo(pop(last) - pop(current));
            ans %= MOD;
        } else {
            ans = 0;
        }
        System.out.println(ans);
    }
    
    static long kaijo(int x) {
        if (x == 0) {
            return 1;
        } else {
            return x * kaijo(x - 1) % MOD;
        }
    }
    
    static int pop(long x) {
        int count = 0;
        while (x > 0) {
            if (x % 2 == 1) {
                count++;
            }
            x /= 2;
        }
        return count;
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0