ll n, m; voidsolve() { cin >> n >> m; ll ans = n*m; int f = 0; if (m >= 2) { f++; ans -= 2 * n; } if (n >= 2) { f++; ans -= 2 * m; } if(f==2)ans += 4; cout << ans << endl; }
D Remainder Reminder
找出不超过$n$中,有多少对$(a,b)$,使得$a%b >= k$
枚举$b$。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ll n, k; voidsolve() { slla(n), slla(k); ll ans = 0; repp(x, k + 1, n) { ll f = n / x; ll num = x - k; ans += num*f; ll sur = n%x + 1; ans += max(sur - k, 0LL); } if (!k)ans = n*n; cout << ans << endl; }