Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main() {
- long long a, b;
- cin >> a >> b;
- long long result;
- if (a < b)
- result = (b - a + 1) * (a + b) / 2;
- else
- result = (a - b + 1) * (b + a) / 2;
- cout << result;
- return 0;
- }
Add Comment
Please, Sign In to add comment