fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. long long int a,b,c=0,e,f,d;
  7. cin>>a>>b;
  8. if(b<a)
  9. {
  10. swap(a,b);
  11. }
  12. d=(b*(b+1))/2;
  13. e=a-1;
  14. f=(e*(e+1))/2;
  15. cout<<d-f<<"\n";
  16. // your code goes here
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5540KB
stdin
12 8
stdout
50