Skip to content

Commit 4201196

Browse files
committed
Change the order of operation in case of the overflow
1 parent 6e2b258 commit 4201196

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

atcoder/math.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ std::pair<long long, long long> crt(const std::vector<long long>& r,
8282
long long floor_sum(long long n, long long m, long long a, long long b) {
8383
long long ans = 0;
8484
if (a >= m) {
85-
ans += (n - 1) * n * (a / m) / 2;
85+
ans += (n - 1) * n / 2 * (a / m);
8686
a %= m;
8787
}
8888
if (b >= m) {

0 commit comments

Comments
 (0)