結果

問題 No.462 6日知らずのコンピュータ
ユーザー bal4ubal4u
提出日時 2019-06-26 06:19:39
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,640 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 30,008 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-06 03:18:47
合計ジャッジ時間 3,572 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 0 ms
4,376 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 0 ms
4,380 KB
testcase_24 AC 0 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 0 ms
4,380 KB
testcase_28 AC 0 ms
4,380 KB
testcase_29 AC 0 ms
4,376 KB
testcase_30 AC 0 ms
4,380 KB
testcase_31 AC 0 ms
4,376 KB
testcase_32 AC 0 ms
4,376 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 0 ms
4,376 KB
testcase_35 AC 0 ms
4,380 KB
testcase_36 AC 0 ms
4,388 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 0 ms
4,380 KB
testcase_46 AC 0 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,384 KB
testcase_49 AC 1 ms
4,384 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 0 ms
4,380 KB
testcase_57 AC 0 ms
4,384 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 0 ms
4,380 KB
testcase_60 AC 0 ms
4,380 KB
testcase_61 WA -
testcase_62 AC 0 ms
4,376 KB
testcase_63 WA -
testcase_64 AC 1 ms
4,376 KB
testcase_65 AC 1 ms
4,376 KB
testcase_66 AC 1 ms
4,376 KB
testcase_67 AC 0 ms
4,380 KB
testcase_68 AC 0 ms
4,376 KB
testcase_69 AC 0 ms
4,376 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 1 ms
4,380 KB
testcase_72 AC 1 ms
4,376 KB
testcase_73 AC 1 ms
4,380 KB
testcase_74 AC 1 ms
4,376 KB
testcase_75 AC 0 ms
4,380 KB
testcase_76 AC 0 ms
4,376 KB
testcase_77 AC 1 ms
4,380 KB
testcase_78 AC 1 ms
4,380 KB
testcase_79 AC 1 ms
4,380 KB
testcase_80 AC 1 ms
4,376 KB
testcase_81 AC 0 ms
4,376 KB
testcase_82 AC 0 ms
4,376 KB
testcase_83 AC 1 ms
4,380 KB
testcase_84 AC 1 ms
4,376 KB
testcase_85 AC 0 ms
4,376 KB
testcase_86 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:10:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   10 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:16:27: 備考: in expansion of macro ‘gc’
   16 |         ll n = 0; int c = gc();
      |                           ^~

ソースコード

diff #

// yukicoder: No.462 6日知らずのコンピュータ
// 2019.6.26 bal4u

#include <stdio.h>

typedef long long ll;
typedef unsigned long long ull;

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

ll in() {   // 非負整数の入力
	ll n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

// 64ビット用
int bitcount64(unsigned long long x)
{
	x = ((x & 0xAAAAAAAAAAAAAAAAULL) >> 1 ) + (x & 0x5555555555555555ULL);
	x = ((x & 0xCCCCCCCCCCCCCCCCULL) >> 2 ) + (x & 0x3333333333333333ULL);
	x = ((x & 0xF0F0F0F0F0F0F0F0ULL) >> 4 ) + (x & 0x0F0F0F0F0F0F0F0FULL);
	x = ((x & 0xFF00FF00FF00FF00ULL) >> 8 ) + (x & 0x00FF00FF00FF00FFULL);
	x = ((x & 0xFFFF0000FFFF0000ULL) >> 16) + (x & 0x0000FFFF0000FFFFULL);
	x = ((x & 0xFFFFFFFF00000000ULL) >> 32) + (x & 0x00000000FFFFFFFFULL);
	return (int)x;
}

#define MOD 1000000007
ll a[65]; int dp[65];
int n[65];
int N, k;

int check(ll new, ll pre) {
	ll k;
	for (k = 1; k <= pre; k <<= 1) {
		if ((new & k) == 0 && (pre & k)) return 0;
	}
	return 1;
}

int main()
{
	int i, j, ans;
	ll aa;
	
	n[0] = n[1] = 1; for (i = 2; i <= 60; i++) n[i] = (ll)n[i-1]  * i % MOD;
	N = (int)in(), k = (int)in();
	if (k == 0) { printf("%d\n", n[N]); return 0; }
	if (k == N+1) { puts("1"); return 0; }
	for (i = 0; i < k; i++) {
		ll _a = in();
		j = bitcount64(_a);
		if (a[j] > 0) goto Err;
		a[j] = _a;
	}
	j = 0, dp[0] = 1;
	for (i = 1; i < N; i++) if (a[i]) {
		if (!check(a[i], a[j])) goto Err;
		dp[i] = (ll)dp[j] * n[i-j] % MOD;
		j = i;
	}
	dp[N] = (ll)dp[j] * n[N-j] % MOD;
	printf("%d\n", dp[N]);
	return 0;
Err:puts("0");
	return 0;
}
0