Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (ll i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define ld long double
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, false, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define mod 1000000007
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
ll get(int n, int k)
{
if (n & (1 << k))
return 1;
else
return 0;
}
int main()
{
ll t;
cin >> t;
while (t--)
{
ll a,b,c;cin>>a>>b>>c;
ll mx = max(max(a,b),c);
ll n = ceil(log2((ld)mx+1));
//deb(n);
ll C = 0;
fo(i,n){
ll x = get(a,i);
ll y = get(b,i);
ll z = get(c,i);
// deb(x);deb(y);deb(z);deb(C);
if(C>0){
if(x == y && x==1 && z == 0) C = 0;
else if(x == y && x==0 && z == 1) C = 0;
}
else{
if(x == y && x==1 && z == 0) C = 1;
else if(x == y && x==0 && z == 1) C = 1;
}
}
if(C>0) cout<<"NO"<<"\n";
else cout<<"YES"<<"\n";
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nline "\n"
#define ll long long
#define pub push_back
#define ull unsigned long long
#define pii pair<ll,ll>
#define lld long double
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,k,n) for (ll i = k; i <= n; ++i)
#define REPR(i,k,n) for (ll i = k; i >= n; --i)
#define mod 1000000007
#define ff first
#define ss second
#define vpi vector<pair<int,int>>
#define all(x) (x).begin(),(x).end()
const ll inf = 1e17;
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
// this is stderr print
void _print(ll t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
//this is stdout print
void print(ll t) {cout << t;}
void print(string t) {cout << t;}
void print(char t) {cout << t;}
void print(lld t) {cout << t;}
void print(double t) {cout << t;}
void print(ull t) {cout << t;}
template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T, class V> void print(pair <T, V> p) { print(p.ff); cout << " "; print(p.ss); }
template <class T> void print(vector <T> v) { for (T i : v) {print(i); cout << " ";} }
template <class T> void print(set <T> v) { for (T i : v) {print(i); cout << " ";} }
template <class T> void print(multiset <T> v) { for (T i : v) {print(i); cout << " ";} }
template <class T, class V> void print(map <T, V> v) { for (auto i : v) {print(i); cout << "\n";}}
//use ll along with accumulate's 2nd param
void solve()
{
ll a,b,c;
cin>>a>>b>>c;
ll x=0;
bool carry=false;
for(int i=0;i<30;i++){
ll first=(((1<<i)&a)>0);
ll second=(((1<<i)&b)>0);
ll third=(((1<<i)&c)>0);
if(carry){
if(first==0 and second==0 and third==1)carry=false;
else if(first==1 and second==1 and third==0)carry=false;
}
else{
if(first==0 and second==0 and third==1)carry=true;
else if(first==1 and second==1 and third==0)carry=true;
}
}
if(carry){
cout<<"NO";
}
else
cout<<"YES";
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("error.txt", "w", stderr);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t = 1;
cin >> t;
while(t--)
{
solve();
cout << "\n";
}
return 0;
}
import sys
from math import *
from collections import *
inp = lambda: sys.stdin.buffer.readline().decode().strip()
out=sys.stdout.write
# n=int(inp())
# arr=list(map(int,inp().split()))
for _ in range(int(inp())):
a,b,c=map(int,inp().split())
sa="{0:b}".format(int(a))
sb="{0:b}".format(int(b))
sc="{0:b}".format(int(c))
sa="0"*(27-len(sa))+sa
sb="0"*(27-len(sb))+sb
sc="0"*(27-len(sc))+sc
carry=0
for i in range(27):
ai,bi,ci=int(sa[i]),int(sb[i]),int(sc[i])
if (ai,bi,ci)==(0,0,1) or (ai,bi,ci)==(1,1,0):
if carry==1:
carry=0
else:
carry=1
if carry==0:
print("YES")
else:
print("NO")
#include <stdio.h>
#include <stdbool.h>
int main() {
int A, B, C;
int testcase;
scanf("%d", &testcase);
while (testcase--) {
scanf("%d%d%d", &A, &B, &C);
int solve = A + B;
if (solve == C) {
puts("Yes");
}
else {
bool carry = 0;
for (int i = 0; (1 << i) <= A + B + C; i++) {
bool b1 = (A >> i) & 1;
bool b2 = (B >> i) & 1;
bool b3 = (C >> i) & 1;
if (b1 == b2 && b2 != b3)
carry = !carry;
}
puts(carry ? "No" : "Yes");
}
}
}
import java.io.*;
import java.util.*;
public class Main {
static MyScanner sc = new MyScanner();
static PrintWriter out = new PrintWriter(System.out);
static int MOD = 998244353;
static ArrayList<ArrayList<Integer>> m;
public static void main(String[] args) {
int t = 1;
t = sc.nextInt();
while (t-- != 0)
solve();
out.flush();
}
static void solve() {
int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),y=31,co=0;
while(y--!=0) {
if(a==0 && b==0 && c==0 && co==0) {
out.println("YES");return;
}
int m=a&1,n=b&1,o=c&1;
if(co==1)
o=(o+1)%2;
int x=get(m,n,o);
int s=(m^x) + (n^x) +co;
co=s/2;
a>>=1;b>>=1;c>>=1;
}
out.println("NO");
}
static int get(int a,int b,int c) {
if(a==0) return (b^c);
return (~(b^c))&1;
}
/*
lower(int a[],int n) // index of last element less than n.(not equal to)
higher(int a[],int n) // index of first element greater than n(not equal to)
sieveArr(int n) // boolean array of prime numbers from [1,n]
sieveIntArr(int n) // int[] array of prime numbers from [2,n]
power(long a,long n,long mod) // return (a^n)%m
isPrime(int n) // true/false -> prime or not
isPrimeMiller(int n) // true/false -> log n
gcd(long a,long b) // gcd in long
lcm(long a,long b) // lcm in long
ex_gcd(long a,long b) // long[2] x&y such that ax + by = gcd(a,b)
Stack<>
ArrayDeque<>
*/
//================================================
public static int lower(int a[], int n) {
if (n <= a[0])
return -1;
else if (n > a[a.length - 1])
return a.length - 1;
int low = 0, high = a.length - 1;
while (low <= high) {
int mid = (low + high) / 2;
if (a[mid] < n)
low = mid + 1;
else
high = mid - 1;
}
return high;
}
public static int higher(int a[], int n) {
if (n < a[0])
return 0;
else if (n >= a[a.length - 1])
return a.length;
int low = 0, high = a.length - 1;
while (low < high) {
int mid = (low + high) / 2;
if (a[mid] > n)
high = mid;
else
low = mid + 1;
}
return high;
}
public static boolean[] sieveArr(int n) {
boolean b[] = new boolean[n + 1];
Arrays.fill(b, true);
b[1] = b[0] = false;
for (int i = 2; i * i <= n; i++) {
if (b[i]) {
for (int j = i * i; j <= n; j += i)
b[j] = false;
}
}
return b;
}
public static int[] sieveIntArr(int n) {
boolean b[] = new boolean[n + 1];
Arrays.fill(b, true);
b[1] = b[0] = false;
int c = 0;
for (int i = 2; i <= n; i++)
if (b[i]) {
c++;
for (int j = i * i; j <= n; j += i)
b[j] = false;
}
int ar[] = new int[c];
for (int i = 2, j = 0; i <= n; i++)
if (b[i])
ar[j++] = i;
return ar;
}
// Trial division
public static boolean isPrime(int n) {
if (n == 2 || n == 3 || n == 5)
return true;
else if (n < 2)
return false;
else if (n % 2 == 0 || n % 3 == 0)
return false;
else {
int k = (int) Math.sqrt(n);
for (int i = 5; i <= k; i += 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
}
return true;
}
public static long power(long a, long n, long mod) {
long res = 1L;
a = a % mod;
while (n > 0) {
if ((n & 1) == 1)
res = (res * a) % mod;
n >>= 1;
a = (a * a) % mod;
}
return res;
}
// ============
// F[0]=0,F[1]=1,F[2]=1,F[3]=2,F[4]=3,F[5]=5,F[6]=8,F[8]=13,...
// FORMULA:-
// (F[n] F[n+1])=(F[0] F[1])*(P^n)
// _ _
// p= |0 1|
// |1 1|
// - -
// Miller Rabin Test: (a^(p-1) % p != 1)
static boolean check_composite(long n, long a, long d, int s) {
long x = power(a, d, n);
if (x == 1 || x == n - 1)
return false;
for (int r = 1; r < s; r++) {
x = (x * x) % n;
if (x == n - 1)
return false;
}
return true;
}
static boolean isPrimeMiller(long n) { // returns true if n is prime, else returns false.
if (n < 2)
return false;
int r = 0;
long d = n - 1;
while ((d & 1) == 0) {
d >>= 1;
r++;
}
int ar[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 };
for (int a : ar) {
if (n == a)
return true;
if (check_composite(n, a, d, r))
return false;
}
return true;
}
public static long gcd(long a, long b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
public static long lcm(long a,long b){
return (a*b)/gcd(a,b);
}
public static long[] ex_gcd(long a,long b) {
if(b==0)
return new long[] {1,0};
long ar[]=ex_gcd(b,a%b);
return new long[] {ar[1],ar[0]-ar[1]*(a/b)};
}
static class MyScanner {
BufferedReader br;
StringTokenizer st;
public MyScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public MyScanner(String problemName) throws IOException {
br = new BufferedReader(new FileReader(problemName + ".in"));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
public int[] nextIntArr(int n) {
int a[] = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public long[] nextLongArr(int n) {
long a[] = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public double[] nextDoubleArr(int n) {
double a[] = new double[n];
for (int i = 0; i < n; i++)
a[i] = nextDouble();
return a;
}
public String[] nextArr(int n) {
String a[] = new String[n];
for (int i = 0; i < n; i++)
a[i] = next();
return a;
}
public String[] nextLineArr(int n) {
String a[] = new String[n];
for (int i = 0; i < n; i++)
a[i] = nextLine();
return a;
}
public int[][] nextInt2dArr(int n, int m) {
int a[][] = new int[n][m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
a[i][j] = nextInt();
return a;
}
public long[][] nextLong2dArr(int n, int m) {
long a[][] = new long[n][m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
a[i][j] = nextLong();
return a;
}
public double[][] nextDouble2dArr(int n, int m) {
double a[][] = new double[n][m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
a[i][j] = nextDouble();
return a;
}
public char[] nextCharArr() {
return next().toCharArray();
}
public char[][] nextChar2dArr(int n, int m) {
char[][] ch = new char[n][m];
for (int i = 0; i < n; i++)
ch[i] = nextCharArr();
return ch;
}
}
}
"""THIS TEMPLATE belongs to anuj_negi"""
#Try to use bisect in case of binary search, bisect_left, bisect_right
#Try to use sortedcontainers when available
#Try to use Multiset when available
from bisect import *
from heapq import *
#from functools import cache, lru_cache
from math import *
from collections import defaultdict as ddc
from collections import Counter
from functools import *
from itertools import *
from sys import setrecursionlimit
import io,os
into = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def input(): return into().decode().strip()
def intin(): return int(input())
def mapin(): return map(int, input().split())
def strin(): return input().split()
def graphin(m):
zz = ddc(set)
for i in range(m):
a, b = mapin()
zz[a].add(b)
zz[b].add(a)
return zz
#----------------------------------------------
INF = 1<<64 #Or use 10**20
mod = 10**9 + 7
#----------------------------------------------
"""
SOME FACTS THAT CAN BE USED LATER -
-> if n is prime, then -> (a**(n-1)) % n = 1
-> When cases like DEFICIENT CITY to SURPLUS CITY, work on BFS using SURPLUS city and check for DEFICIENT city
-> PALINDROMEs and str-len FACTORS have some relations. if P = XQ where P, X, Q are palindromes, then X have the possible length in Factors of 'n'
-> When all substrings are said to be checked, we can go for 2 loops (With 100 limit of inner loop, minimize the memory)
"""
#----------------------------------------------
"""
-> THIS IS A Interval Based Segmented Trees
-> Can be modified or used later for similar
"""
class IntervalSeg:
def __init__(self):
self.Seg = ddc(int)
self.otherAdded = ddc(int)
def update(self, s, e, l = 0, r = 10**9, index = 1):
if r<=s or e<=l: return
if s<=l<r<=e:
self.Seg[index]+=1
self.otherAdded[index]+=1
else:
m = (l+r)//2
self.update(s, e, l, m, 2*index)
self.update(s, e, m, r, 2*index + 1)
self.Seg[index] = self.otherAdded[index] + max(self.Seg[2*index], self.Seg[2*index + 1])
def use(self, start, end):
self.update(start, end)
return self.Seg[1]
#----------------------------------------------
#FOR nCr
class nCr:
def __init__(self):
self.fact = [1]*(1000001)
self.factinv = [1]*(1000001)
for i in range(1, 1000001):
self.fact[i] = self.fact[i-1] * i % mod
self.factinv[-1] = exponentiation(self.fact[-1], mod-2, mod)
for i in range(1000000-1, 1, -1):
self.factinv[i] = self.factinv[i+1] * (i+1) % mod
def C(self, n, r):
if n<r or r<0: return 0
return self.fact[n] * self.factinv[r] % mod * self.factinv[n-r] % mod
#----------------------------------------------
#Use this when really needed
# Such as - Getting TLE because some TC can cause O(n^2) on pre-built HASHMAPS
def custom_hash(x):
return x // 1000000007, x % 1000000007
#----------------------------------------------
#Subarray size - Rolling Hash - Custom
def hash_it(arr, size, mod = (10**9 + 7)):
"""
mul -> must be greater than max(arr)
rest can be modified
"""
if not size: return
mul, hashh, div = 256, 0, (1<<(8*size-8))%mod
C = ddc(list)
for i in range(size):
hashh = (mul * hashh + arr[i])%mod
C[hashh].append(0)
for i in range(len(arr)-size):
#update the hashh
hashh = (mul*(hashh-arr[i]*div) + arr[i+size])%mod
C[hashh].append(i+1)
return C
#----------------------------------------------
def LIS(arr, n):
dp = [10**9]*(n+1)
for ele in arr:
dp[bisect_left(dp, ele)] = ele
#print(dp)
return bisect_left(dp, 10**9)
#----------------------------------------------
#Fast base^exp
def exponentiation(bas, exp, mod = 10**9 + 7):
t = 1
while(exp > 0):
if (exp % 2 != 0):
t = (t * bas) % mod
bas = (bas * bas) % mod
exp //= 2
return t % mod
#----------------------------------------------
#Fast multiplication
def fastMul(a, b, mod = 10**9 + 7):
t = 0
while(b > 0):
if (b % 2 != 0):
t = (t + a) % mod
a = (a + a) % mod
b //= 2
return t % mod
#----------------------------------------------
#Returns P*Q^-1 % Mod
def modInv(p, q=1, mod = 10**9 + 7):
expo = 0
expo = mod - 2
while (expo):
if (expo & 1):
p = (p * q) % mod
q = (q * q) % mod
expo >>= 1
return p
#----------------------------------------------
def sortArrayMinSwap(arr, n):
#O(nlogn)
ans = 0
Another = {ele:i for i, ele in enumerate(sorted(arr))}
complete = [True]*n
for j in range(n):
i = j
curr = 0
while complete[i]:
complete[i] = False
i = Another[arr[i]]
curr+=1
if curr>0:
ans += curr-1
return ans
#----------------------------------------------
yes = "YES"
no = "NO"
even = "EVEN"
odd = "ODD"
alice = "ALICE"
bob = "BOB"
#----------------------------------------------
def process(arr):
a,b,c = arr
x = 1
ff = lambda x: x&1
for i in range(32):
temp = 1<<i
aa, bb, cc = ff(a>>i), ff(b>>i), ff(c>>i)
#print(aa,bb,cc)
if aa==bb and bb!=cc:
x^=1
return yes if x else no
def main():
#T-testcases
for _ in range(int(input())):
arr = list(mapin())
ans = process(arr)
print(ans)
#print("Case #{0}: {1}".format(_+1, ans))
#--------------------------
if __name__ == "__main__":
main()
process.stdin.resume();
process.stdin.setEncoding('utf8');
// your code goes here
// declare global variables
var input_stdin = "";
var lines = "";
var input_currentline = 0;
// standard input is stored into input_stdin
process.stdin.on('data', function (data) {
input_stdin += data;
});
// standard input is done and stored into an array
process.stdin.on('end', function () {
lines = input_stdin.split("\n");
start();
});
function start() {
t = parseInt(lines[0])
let line = 1
while (t > 0) {
let [A, B, C] = lines[line++].split(' ').map(x => parseInt(x))
let overflow = 0
let num = [0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1]
let dic = {
'0000': 0,
'0001': 1,
'0010': 1,
'0011': 0,
'0100': 0,
'0101': 1,
'0110': 0,
'0111': 1,
'1000': 0,
'1001': 1,
'1010': 0,
'1011': 1,
'1100': 1,
'1101': 0,
'1110': 0,
'1111': 1
}
while ((A > 0) || (B > 0) || (C > 0)) {
overflow = num[((A & 1) << 3) + ((B & 1) << 2) + ((C & 1) << 1) + (overflow)]
A >>= 1
B >>= 1
C >>= 1
}
console.log(overflow ? 'NO' : 'YES')
t--
}
}
package main
import (
"bufio"
"bytes"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
var buf bytes.Buffer
tc := readNum(reader)
for tc > 0 {
tc--
A, B, C := readThreeNums(reader)
res := solve(A, B, C)
if res {
buf.WriteString("YES\n")
} else {
buf.WriteString("NO\n")
}
}
fmt.Print(buf.String())
}
func readUint64(bytes []byte, from int, val *uint64) int {
i := from
var tmp uint64
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + uint64(bytes[i]-'0')
i++
}
*val = tmp
return i
}
func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}
func readString(reader *bufio.Reader) string {
s, _ := reader.ReadString('\n')
for i := 0; i < len(s); i++ {
if s[i] == '\n' || s[i] == '\r' {
return s[:i]
}
}
return s
}
func readNum(reader *bufio.Reader) (a int) {
bs, _ := reader.ReadBytes('\n')
readInt(bs, 0, &a)
return
}
func readTwoNums(reader *bufio.Reader) (a int, b int) {
res := readNNums(reader, 2)
a, b = res[0], res[1]
return
}
func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
res := readNNums(reader, 3)
a, b, c = res[0], res[1], res[2]
return
}
func readNNums(reader *bufio.Reader, n int) []int {
res := make([]int, n)
x := 0
bs, _ := reader.ReadBytes('\n')
for i := 0; i < n; i++ {
for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
x++
}
x = readInt(bs, x, &res[i])
}
return res
}
func solve(A, B, C int) bool {
dp := make([]bool, 2)
dp[0] = true
fp := make([]bool, 2)
for i := 0; i < 30; i++ {
fp[0] = false
fp[1] = false
a := (A >> i) & 1
b := (B >> i) & 1
c := (C >> i) & 1
for carry := 0; carry < 2; carry++ {
if dp[carry] {
for x := 0; x < 2; x++ {
if ((a^x)+(b^x)+carry)&1 == c^x {
next := (((a ^ x) + (b ^ x) + carry) >> 1) & 1
fp[next] = true
}
}
}
}
copy(dp, fp)
}
return dp[0]
}
In our experience, we suggest you solve this Existence Of X CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Existence Of X CodeChef Solution.
I hope this Existence Of X CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.
Keep Learning!