Recently I have done [problem:711C], and I have found an overflow when I use min(a,b) function. More specifically, if I use:↵
↵
min(a, b + c) when a, b and c are long long and sum of b + c large than 32-bit integer then the sum b + c will be treated as 32-bits integer and hence the overflow.↵
↵
↵
but let say, if I use a temporary variable:↵
↵
long long tmp = b + c↵
↵
then↵
↵
min(a, tmp) will not overflow↵
↵
↵
What kind of behavior is this?↵
↵
This is two submissions, one is overflow and the another one use a temporary variable will not overflow:↵
↵
Overflow: [submission:285989412]↵
↵
Not overflow: [submission:286024512]
↵
min(a, b + c) when a, b and c are long long and sum of b + c large than 32-bit integer then the sum b + c will be treated as 32-bits integer and hence the overflow.↵
↵
↵
but let say, if I use a temporary variable:↵
↵
long long tmp = b + c↵
↵
then↵
↵
min(a, tmp) will not overflow↵
↵
↵
What kind of behavior is this?↵
↵
This is two submissions, one is overflow and the another one use a temporary variable will not overflow:↵
↵
Overflow: [submission:285989412]↵
↵
Not overflow: [submission:286024512]