Created
October 9, 2018 14:12
-
-
Save completejavascript/0b05c37ae33f445f80f0e613050c4c8a 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
#include <iostream> | |
using namespace std; | |
long long sumAll(long long a, long long b) { | |
long long n; | |
if (b > a) n = b - a + 1; | |
else n = a - b + 1; | |
return n * (a + b) / 2; | |
} | |
int main() { | |
ios::sync_with_stdio(false); | |
//freopen("input.txt", "r", stdin); | |
int a, b; | |
while(cin >> a >> b) { | |
cout << sumAll(a, b) << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment