結果

問題 No.822 Bitwise AND
ユーザー pekempeypekempey
提出日時 2019-04-26 21:36:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,268 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 69,752 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 01:07:22
合計ジャッジ時間 16,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,244 ms
4,380 KB
testcase_01 AC 29 ms
4,376 KB
testcase_02 AC 8 ms
4,376 KB
testcase_03 AC 12 ms
4,376 KB
testcase_04 AC 1,250 ms
4,380 KB
testcase_05 AC 591 ms
4,376 KB
testcase_06 AC 1,066 ms
4,380 KB
testcase_07 AC 1,249 ms
4,376 KB
testcase_08 AC 1,268 ms
4,376 KB
testcase_09 AC 1,080 ms
4,380 KB
testcase_10 AC 1,153 ms
4,384 KB
testcase_11 AC 1,237 ms
4,380 KB
testcase_12 AC 1,194 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 1,236 ms
4,376 KB
testcase_15 AC 687 ms
4,376 KB
testcase_16 AC 14 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int f(int N, int K, int L) {
  int ans = 0;
  for (int i = 0; i <= L; i++) {
    for (int j = i; j <= i+K; j++) {
      if ((i & j) == N) {
        ans++;
      }
    }
  }
  return ans;
}

int main() {
  int N, K;
  cin >> N >> K;
  int ans = f(N, K, 1000000);
  int ans2 = f(N, K, 2000000);
  if (ans != ans2) {
    cout << "INF" << endl;
  } else {
    cout << ans << endl;
  }
}
0