标签:space string 大于等于 std clu signed 进制 ref ORC
给定一幅无限节点的有向图,顶点u指向顶点u+v的充要条件是 \(u\&v=v\) 。
现在有q组询问,每次询问给出u,t,问:能否从u到t,回答 yes/no
找规律...
以下皆为2进制
证明从心(
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define ull unsigned long long
#define cint const int&
#define Pi acos(-1)
const int mod = 1e9+7;
const int inf_int = 0x7fffffff;
const ll inf_ll = 0x7fffffffffffffff;
const double ept = 1e-9;
int q;
bool check(int f, int t) {
if(f > t) return 0;
if(f == t) return 1;
int r = 0, s = 0;
while(t) {
if(f) {
if(!(f&1)) -- r;
else -- s;
f >>= 1;
}
if(!(t&1)) ++ r;
else ++ s;
t >>= 1;
if(r < 0) return 0;
}
if(s > 0) return 0;
return 1;
}
int main() {
cin >> q;
while(q--) {
int u, v;
cin >> u >> v;
if(check(u, v)) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}
30min, -1
标签:space string 大于等于 std clu signed 进制 ref ORC
原文地址:https://www.cnblogs.com/ullio/p/14495078.html