Source Code
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long l,r,x,y,k;
    cin>>l>>r>>x>>y>>k;
    long long sum=0,np=0,n;
    n=l;
    for(long long i=0; i<n; i++)
    {
        if(np==k)
        {
            sum+=y;
            np=0;
        }
        if(l!=0)
        {
            sum+=x;
            np++;
            cout<<'1';
        }
        l-=1;
    }
    np=0;
    n=r;
    for(long long i=0; i<n; i++)
    {
        if(np==k)
        {
            sum+=y;
            np=0;
        }
        if(r!=0)
        {
            r--;
            sum+=x;
            np++;
        }

    }
    cout<<sum;
    return 0;
}
Copy
Practice Practice Mohamedmaher
GNU G++17
3 ms
240 KB
Wrong Answer