Created
September 22, 2016 05:39
-
-
Save yurahuna/962fd2d9ea8f5c8332a69721afa3d2dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signed main() { | |
std::ios::sync_with_stdio(false); | |
std::cin.tie(0); | |
int n, d; | |
cin >> n >> d; | |
int ans; | |
if (d == 1) { | |
ans = n * (n - 1) / 2; | |
} else { | |
ans = (n - 1) + (n - d - 1) * n - (n - d - 1) * (n + d - 2) / 2; | |
} | |
cout << ans << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment