Online Course Discussion Forum

USACO: Is there a java type that has a big capacity and can do the bitwise shift operator?

 
 
Picture of Dr. Kevin Wang
Re: USACO: Is there a java type that has a big capacity and can do the bitwise shift operator?
by Dr. Kevin Wang - Friday, January 27, 2023, 2:07 PM
 

Be careful when the length of the reversal is odd; the result may be different from what you think.

If the bitwise operation for long strings of 0s and 1s is critical to your algorithm, you could write a helper class to represent that data type. In the helper class, represent the big capacity string with an array of long, and write methods for add digit, shift, complement, bitwise AND, bitwise OR, etc.