Source Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define AiBak_is_Here main
int AiBak_is_Here()
{
    ll l,r,x,y,k,sum=0,sum1=0,mi=0,c=0,value=0;
    cin>>l>>r>>x>>y>>k;
    sum=r*(r+1)/2-(l-1)*l/2;

    for(ll i=k;i<=r;i+=k)
    {
        c++;
        if(i>=l && i<=r  )
        {
            if(i+k<=r)
            {
            value+=k*c*y%(1000000000+7);
            }
            else
            {
                value+=(r-i+1)*c*y%(1000000000+7);
            }
            mi++;
        }
    }
     mi*=y;
    sum1+=value%(1000000000+7)+(sum%(1000000000+7))*x-mi%(1000000000+7);

    cout<<sum1;


}

Copy
Practice Practice ai365ak
GNU G++17
210 ms
488 KB
Wrong Answer