Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

tgbaodeeptry's blog

By tgbaodeeptry, history, 5 years ago, In English

Assume I have 3 long long varables a, b and n. And them are approximately (max long long)( 2.10^18 ).

So, are there any ways that I can check if a + b is larger than n?

Thanks so much guys

  • Vote: I like it
  • +22
  • Vote: I do not like it

| Write comment?
»
5 years ago, hide # |
 
Vote: I like it +54 Vote: I do not like it

Yes. Since a + b > n means a > n - b you can just check that.

»
5 years ago, hide # |
 
Vote: I like it -57 Vote: I do not like it

Convert them all to double.

»
5 years ago, hide # |
 
Vote: I like it +21 Vote: I do not like it
»
5 years ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

ive seen people use logs like log(a) + log(b) >= 18 or something along those lines. personally I just ll overflow each time so I don't use it