• Source
    1. #include <iostream>
    2. using namespace std;
    3. int main()
    4. {
    5. int a,b,c,d;
    6. cin>>a>>b>>c>>d;
    7. if(c<d)
    8. cout<<(d-c)*2*b+(d-c-1)*a;
    9. else
    10. if(c==d)
    11. cout<<a;
    12. else
    13. cout<< (c-d)*2*b+(c-d+1)*a;
    14. return 0;
    15. }
    16.