poj3495 bitwise XOR of arithmetic progression arithmetic progression xor or __ number theory

Source: Internet
Author: User
Tags arithmetic bitwise
Meaning

is to seek arithmetic progression or
X represents the first item, Y represents the last item, and z indicates what the tolerance does.

Arithmetic progression and, I will! (first + last item) * Number/2
But that's not the problem.
Because of the specificity of different or, so we can one to consider
We define a function f (a,b,c,n) f (a,b,c,n) to denote that the first item is a, the tolerance is b b, c c is a divisor, n n is the number of items and
For the first I, the last one is called the No. 0 digit, from right to left
All we need to know is parity of f (X,z,2i,⌊ (y−x)/z⌋+1) F (X,z,2^i,\lfloor (y-x)/z \rfloor + 1)
So we decided to use the simplest and most brutal way, that is to sum.
The equivalence we are asking now is the same as the following equation
∑i=0n−1⌊x+z∗ic⌋\sum_{i=0}^{n-1}\lfloor \frac{x+z*i}{c} \rfloor
Obviously, the equation can become the following one
∑i=0n−1⌊xc⌋ (⌊zc⌋i) ⌊x%c+z%c∗ic⌋\sum_{i=0}^{n-1}\lfloor\frac{x}{c}\rfloor (\lfloor\frac{z}{c}\rfloor i) \lfloor \ FRAC{X\%C+Z\%C*I}{C} \rfloor
So the first two parts, we can even come out at the beginning, it doesn't matter.
Then the only thing left is the one behind.
∑i=0n−1⌊x%c+z%c∗ic⌋\sum_{i=0}^{n-1}\lfloor \frac{x\%c+z\%c*i}{c} \rfloor
So how to ask for it.
We can think of him as a about I, The Intercept is ⌊x%cc⌋\lfloor \frac{x\%c}{c} \rfloor, the slope is ⌊z%c

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.