F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Xor

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 491    Accepted Submission(s): 235


Problem Description
Given $A,B,K,W$, Kanade wants to know the number of $(x,y)$ which satisfies the following conditions:

1. $x,y$ are integers

2. $x\in [0,A],y\in [0,B]$

3. $|x-y|\leq K$

4. $x~xor~y\leq W$
 

Input
There are $T$ test cases in this problem.

The first line has 1 integer $T$.

Then for every test case, the first line has 4 integers $A,B,K,W$

$1\leq T\leq 2000$

$0\leq A,B,K,W\leq 10^9$
 

Output
For every test case, output the answer in a line.
 

Sample Input
3 3 3 1 2 10 10 3 7 998244353 998244353 114514 123456789
 

Sample Output
8 53 228430202591616
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-03-29 22:43:29, Gzip enabled