From 728d3da95ef601092b2b58cbad0fef900ab4c849 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 21 May 2022 20:11:36 +0800 Subject: [PATCH] =?UTF-8?q?P2261=20[CQOI2007]=E4=BD=99=E6=95=B0=E6=B1=82?= =?UTF-8?q?=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.luogu.com.cn/record/76170293 --- Luogu/P2261/P2261.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Luogu/P2261/P2261.cpp diff --git a/Luogu/P2261/P2261.cpp b/Luogu/P2261/P2261.cpp new file mode 100644 index 00000000..c5644ce7 --- /dev/null +++ b/Luogu/P2261/P2261.cpp @@ -0,0 +1,29 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +long long n, k, ans; + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n >> k; + + ans = n * k; + + for (long long l = 1, r; l <= n; l = r + 1) { + if (k / l) { + r = std::min(k / (k / l), n); + } else { + r = n; + } + + ans -= (r + l) * (k / l) * (r - l + 1) / 2; + } + + cout << ans << endl; + + return 0; +}