a53

Intalnire

a53
Mar 14th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int a,b,d,da,db,ob,oba,obb;
  4.  
  5. int main()
  6. {
  7. cin>>a>>b;
  8. if(a>b)
  9. swap(a,b);
  10. d=b-a;
  11. ob=d*(d+1)/2;
  12. da=d/2;
  13. db=d-da;
  14. oba=da*(da+1)/2;
  15. obb=db*(db+1)/2;
  16. if(ob<(oba+obb))
  17. cout<<ob;
  18. else
  19. cout<<(oba+obb);
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment