結果

問題 No.822 Bitwise AND
ユーザー kenken714kenken714
提出日時 2019-04-26 22:16:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,384 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 23:05:53
合計ジャッジ時間 1,395 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll s[30];
ll n, m, now, ans, mx;
vector<ll> list, l2;
int main() {

	cin >> n >> m;
	ll nn = n;
	while (n > 0) {
		if (n % 2 == 1) {
			s[now] = 1;
			mx = now;
		}
		now++;
		n /= 2;
	}
	if (1 + nn <= m) {
		cout << "INF" << endl;
		return 0;
	}
	REP(i, 11) {
		if (s[i] == 0)list.push_back(pow(2, i));
		if (s[i] == 0)l2.push_back(pow(2, i));
	}

	REP(i, 1ll << (ll)list.size()) {
		REP(k, 1ll << (ll)l2.size()) {
			bool ok = true;
			REP(j, l2.size()) {
				if (i & (1ll << j) and k & (1ll << j))ok = false;
			}
			if (!ok)break;
			ll s1 = 0, s2 = 0;
			REP(j, list.size()) {
				if (i & (1ll << j))s1 += list[j];
			}
			REP(j, l2.size()) {
				if (k & (1ll << j))s2 += l2[j];
			}
			if (s1 < s2)break;
			if (m >= abs(s1 - s2))ans++;

		}
	}
	cout << ans << endl;
}
0