fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // Input
  6. int a, b; cin >> a >> b;
  7.  
  8. // Process -> Output
  9. if (a > b) swap(a, b);
  10. long long sum = 0;
  11. for (int i = a; i <= b; ++i)
  12. sum += i;
  13. cout << sum;
  14.  
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.01s 5296KB
stdin
3 10
stdout
52