How to solve this problem ?

Правка en1, от papa-ka-para, 2023-04-01 15:13:33

we are given 4 integers, where a <= b , c <= d.

We have to find Sum of Xor of all the pairs (i,j) such that ( a <= i <= b , && c <= j <= d )


int sum = 0; for(int i=a ; i <= b; i++) { for(int j = c; j <= d ; j++) { sum += (i ^ j) } } return sum;

How to find this sum optimally ?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский papa-ka-para 2023-04-01 15:13:33 358 Initial revision (published)