SCALSUM - Editorial

what is the difference between 2 and 3 subtasks?

Read this comment.!

1 Like

How unsigned int helps in 2^32 modulo?

Thanks in advance.

Any number data type such as int, uint, long long or u long long, rolls over to other side when an overlow occurs.

For example:

  • The range of int is -{2^{31}} to {2^{31}-1}. But if you initialize an integer to be {2^{31}}, it’ll roll over to the -ve side, and the value stored would be -{2^{31}} .
  • The same way, the range of uint is {0} to {2^{32}-1}. So instead of using % (modulo), as it is a costly operation, we simply use uint so the compiler automatically performs the modulo {2^{32}} by simply rolling over the range.
2 Likes

Why don’t you try removing modulo as discussed in this thread? After that if it doesn’t work then also try changing the block size a bit as sqrt(n) is not always optimal
Also try using unordered map and try optimizing it as discussed in this thread.

At least read the thread or google search before asking.
I don’t wanna spoon feed you.

Thanks a lot for the clarification

Which is better c++or java