Three Dimensions
Time limit1sMemory limit256 MB
Sum the strange distance d(a,b) over all integer point pairs a and b inside two origin-anchored boxes, output modulo 2^30.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Bit manipulation, Math
- Solved
- No attempts yet
Problem
Define a strange distance between two points and in three-dimensional space as follows.
Here is the maximum value in , is the absolute value of , and is the bitwise exclusive-or operator.
Given 6 non-negative integers , find the sum of over all integer points with , , , , , and . Since the sum may be very large, output it modulo .
Input
The input contains 6 non-negative integers , each not larger than .
Output
Output the sum modulo as a single integer.