codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

424C.md (1474B)


      1 Source: https://codeforces.com/problemset/problem/424/C
      2 
      3 C. Magic Formulas
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 People in the Tomskaya region like magic formulas very much. You can see some of them below.
     22 
     23 Imagine you are given a sequence of positive integer numbers *p*1, *p*2, ..., *p**n*. Lets write down some magic formulas:
     24 
     25 ![](https://espresso.codeforces.com/81ab130934a6699fcdd0da19288992c1c610bc69.png)![](https://espresso.codeforces.com/e4038bbd3f52ecb87dbbdd560d05e7810522f6af.png)
     26 
     27 Here, "mod" means the operation of taking the residue after dividing.
     28 
     29 The expression ![](https://espresso.codeforces.com/b364f2e04c665b78b924ec10666327a4ef4635bc.png) means applying the bitwise *xor* (excluding "OR") operation to integers *x* and *y*. The given operation exists in all modern programming languages. For example, in languages C++ and Java it is represented by "^", in Pascal — by "xor".
     30 
     31 People in the Tomskaya region like magic formulas very much, but they don't like to calculate them! Therefore you are given the sequence *p*, calculate the value of *Q*.
     32 
     33 Input
     34 
     35 The first line of the input contains the only integer *n* (1 ≤ *n* ≤ 106). The next line contains *n* integers: *p*1, *p*2, ..., *p**n* (0 ≤ *p**i* ≤ 2·109).
     36 
     37 Output
     38 
     39 The only line of output should contain a single integer — the value of *Q*.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 3  
     47 1 2 3
     48 ```
     49 
     50 Output
     51 
     52 ```
     53 3
     54 ```