Skip to content

Instantly share code, notes, and snippets.

@theortsac
Last active November 14, 2023 20:49
Show Gist options
  • Save theortsac/83dd1d28a0d6ba5ea0f6d2f2afda9c50 to your computer and use it in GitHub Desktop.
Save theortsac/83dd1d28a0d6ba5ea0f6d2f2afda9c50 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k, x;
cin >> n >> k >> x;
if (min(n, x + 1) < k) {
cout << "-1\n";
continue;
}
if (x == k) x--;
cout << k*(k-1)/2 + x*(n-k) << "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment