提交时间:2023-10-04 09:54:23

运行 ID: 104816

#include <iostream> #include <algorithm> #include <cstdio> #include <cmath> using namespace std; int n, p; int main() { scanf("%d %d", &n, &p); long long ans = 2 * n; int l = p; for (int i = 1;i <= n - p;i++) { ans += l - 1; l++; } printf("%lld", ans); return 0; }