結果
問題 |
No.822 Bitwise AND
|
ユーザー |
![]() |
提出日時 | 2019-07-27 16:03:42 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 224 ms / 2,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 29,312 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 18:18:03 |
合計ジャッジ時間 | 1,475 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
// yukicoder: No.822 Bitwise AND // 2019.7.27 bal4u #include <stdio.h> int N, K; char b[20]; int w; int ans; void rec(int id, int x, int y) { if (id == w) { if (y >= x && (y|N) <= K + (x|N)) ans++; return; } if (b[id]) rec(id+1, x, y); else { rec(id+1, x, y); rec(id+1, x, y|(1<<id)); rec(id+1, x|(1<<id), y); } } int main() { int i, n, N, zero; scanf("%d%d", &N, &K); if (N < K) { puts("INF"); return 0; } ans = 1; if (K > 0) { zero = 0, n = N; for (w = 0; n; w++) { if (n & 1) b[w] = 1; else zero++; n >>= 1; } if (zero) { ans = 0, rec(0, 0, 0); } } printf("%d\n", ans); return 0; }