結果

問題 No.462 6日知らずのコンピュータ
ユーザー TententenTententen
提出日時 2020-12-14 18:15:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,330 bytes
コンパイル時間 2,915 ms
コンパイル使用メモリ 77,572 KB
実行使用メモリ 57,892 KB
最終ジャッジ日時 2023-10-20 05:08:31
合計ジャッジ時間 17,284 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,448 KB
testcase_01 AC 131 ms
57,444 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 126 ms
57,204 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 131 ms
57,224 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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 WA -
testcase_35 AC 127 ms
57,196 KB
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 128 ms
57,560 KB
testcase_50 AC 132 ms
57,708 KB
testcase_51 AC 130 ms
57,460 KB
testcase_52 AC 131 ms
57,728 KB
testcase_53 AC 125 ms
57,424 KB
testcase_54 AC 118 ms
56,200 KB
testcase_55 AC 118 ms
56,200 KB
testcase_56 AC 127 ms
57,260 KB
testcase_57 AC 132 ms
57,548 KB
testcase_58 AC 117 ms
56,180 KB
testcase_59 AC 129 ms
57,528 KB
testcase_60 AC 128 ms
57,144 KB
testcase_61 AC 128 ms
57,716 KB
testcase_62 AC 128 ms
57,512 KB
testcase_63 AC 129 ms
57,604 KB
testcase_64 AC 129 ms
55,672 KB
testcase_65 AC 132 ms
57,196 KB
testcase_66 AC 132 ms
57,536 KB
testcase_67 AC 130 ms
57,620 KB
testcase_68 AC 127 ms
57,516 KB
testcase_69 AC 137 ms
57,708 KB
testcase_70 AC 130 ms
57,492 KB
testcase_71 AC 132 ms
57,544 KB
testcase_72 AC 131 ms
57,216 KB
testcase_73 AC 129 ms
57,432 KB
testcase_74 AC 128 ms
57,468 KB
testcase_75 AC 132 ms
57,600 KB
testcase_76 AC 130 ms
57,512 KB
testcase_77 AC 132 ms
57,448 KB
testcase_78 AC 132 ms
57,492 KB
testcase_79 AC 130 ms
57,560 KB
testcase_80 WA -
testcase_81 AC 133 ms
57,524 KB
testcase_82 WA -
testcase_83 WA -
testcase_84 AC 131 ms
57,528 KB
testcase_85 AC 128 ms
57,216 KB
testcase_86 AC 128 ms
57,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] pops = new long[n + 1];
		Arrays.fill(pops, -1);
		pops[0] = 0;
		pops[n] = pow(2, n) - 1;
		for (int i = 0; i < k; i++) {
		    long x = sc.nextLong();
		    if (pops[getPop(x)] != -1) {
		        System.out.println(0);
		        return;
		    }
		    pops[getPop(x)] = x;
		}
		long prev = pops[0];
		long ans = 1;
		int count = 0;
		for (int i = 1; i <= n; i++) {
		    if (pops[i] == -1) {
		        count++;
		        continue;
		    }
		    if ((prev & pops[i]) != prev) {
		        System.out.println(0);
		        return;
		    }
		    ans *= kaijo(count + 1);
		    count = 0;
		    prev = pops[i];
		}
		System.out.println(ans);
	}
	
	static int getPop(long x) {
	    int count = 0;
	    while (x > 0) {
	        count += x % 2;
	        x /= 2;
	    }
	    return count;
	}
	
	static long pow(long x, int p) {
	    if (p == 0) {
	        return 1;
	    } else if (p % 2 == 0) {
	        return pow(x * x, p / 2);
	    } else {
	        return x * pow(x, p - 1);
	    }
	}
	
	static long kaijo(int x) {
	    if (x == 0) {
	        return 1;
	    } else {
	        return x * kaijo(x - 1);
	    }
	}
}
0